FUN & LEARNING WITH ARDUINO PROJECTS ROBOT . HEAD to TOE FUN & LEARNING WITH ARDUINO PROJECTS FUN & LEARNING WITH ARDUINO PROJECTS BEGINNER GUIDE BY Page 2 ROBOT . HEAD to TOE FUN & LEARNING WITH ARDUINO PROJECTS CONTENTS INTRODUCTION 4 PROJECT 7 34 COMPONENT REQUIRED 6 – CONNECTION 34 OVERVIEW OF ARDUINO DUEMILANOVE7 – ADDITIONAL INFORMATION 35 GETTING STARTED 9 – CODE OVERVIEW 35 – ARDUINO IDE 9 PROJECT 8 38 INSTALLATION – CONNECTION 38 – INSTALL THE USB DRIVER 9 – ADDITIONAL INFORMATION 39 – THE ARDUINO IDE SETUP 9 – CODE OVERVIEW 39 – THE ARDUINO IDE 10 PROJECT 9 41 – CONNECTION 41 PROJECT 0 12 – ADDITIONAL INFORMATION 42 – CONNECTION 12 – CODE OVERVIEW 42 – ADDITIONAL INFORMATION 13 PROJECT 10 44 – CODE OVERVIEW 15 – CONNECTION 44 PROJECT 1 17 – CODE OVERVIEW 44 – CONNECTION 17 PROJECT 11 46 – ADDITIONAL INFORMATION 18 – CONNECTION 46 – CODE OVERVIEW 18 – ADDITIONAL INFORMATION 46 PROJECT 2 21 – CODE OVERVIEW 47 – CONNECTION 21 PROJECT 12 49 – ADDITIONAL INFORMATION 21 – CONNECTION 49 – CODE OVERVIEW 21 – CODE OVERVIEW 50 PROJECT 3 23 PROJECT 13 51 – CONNECTION 23 – CONNECTION 51 – ADDITIONAL INFORMATION 24 – ADDITIONAL INFORMATION 51 – CODE OVERVIEW 24 – CODE OVERVIEW 51 PROJECT 4 26 PROJECT 14 53 – CONNECTION 26 – CONNECTION 53 – ADDITIONAL INFORMATION 26 – ADDITIONAL INFORMATION 54 – CODE OVERVIEW 27 – CODE OVERVIEW 55 PROJECT 5 28 – CONNECTION 28 – ADDITIONAL INFORMATION 29 – CODE OVERVIEW 29 PROJECT 6 31 – CONNECTION 31 – ADDITIONAL INFORMATION 32 – CODE OVERVIEW 32 Page 3 ROBOT . HEAD to TOE FUN & LEARNING WITH ARDUINO PROJECTS INTRODUCTION similar functionality. All of these tools take the messy details of microcontroller programming and wrap it up in an easy-to-use package. Arduino also simplifies the process of working with microcontrollers, but it offers some advantage for teachers, students, and interested amateurs over other systems: • Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by hand, and even the pre- assembled Arduino modules cost less than Arduino is a tool for making computers that can sense $50. and control more of the physical world than your desktop computer. It's an open-source physical • Cross-platform - The Arduino software runs computing platform based on a simple on Windows, Macintosh OSX, and Linux microcontroller board, and a development operating systems. Most microcontroller environment for writing software for the board. systems are limited to Windows. Arduino can be used to develop interactive objects, • Simple, clear programming environment - taking inputs from a variety of switches or sensors, The Arduino programming environment is and controlling a variety of lights, motors, and other easy-to-use for beginners, yet flexible physical outputs. Arduino projects can be stand-alone, enough for advanced users to take or they can be communicate with software running on advantage of as well. For teachers, it's your computer (e.g. Flash, Processing, MaxMSP.) The conveniently based on the Processing boards can be assembled by hand or purchased programming environment, so students preassembled; the open-source IDE can be learning to program in that environment will downloaded for free. be familiar with the look and feel of Arduino. The Arduino programming language is an • Open source and extensible software- The implementation of Wiring, a similar physical Arduino software and is published as open computing platform, which is based on the Processing source tools, available for extension by multimedia programming environment. experienced programmers. The language can be expanded through C++ libraries, and WHY ARDUINO? people wanting to understand the technical There are many other microcontrollers and details can make the leap from Arduino to microcontroller platforms available for physical the AVR C programming language on which computing. Parallax Basic Stamp, Netmedia's BX-24, it's based. SImilarly, you can add AVR-C code Phidgets, MIT's Handyboard, and many others offer directly into your Arduino programs if you Page 4 ROBOT . HEAD to TOE FUN & LEARNING WITH ARDUINO PROJECTS want to. • Open source and extensible hardware - The Arduino is based on Atmel's ATMEGA8 and ATMEGA168microcontrollers. The plans for the modules are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. Even relatively inexperienced users can build the breadboard version of the module in order to understand how it works and save money. WHAT YOU WILL NEED Before start any project, make sure you get yourself an Arduino Duemilanove and the necessary Arduino shield that need to use in the coming project. To get the Arduino Duemilanove and other extend shield please click here. 2nd, please download the Arduino software which are required to use to write code and upload to the I/O board here. Lastly, to get improve of yourself, willingness of learning is always a matter. Coming project are design in simple and easy understanding to help you to get involve in microcontroller easily. It's never too hard to learn, just spend some time with it and you will like it. Page 5 ROBOT . HEAD to TOE FUN & LEARNING WITH ARDUINO PROJECTS COMPONENT REQUIRED ARDUINO DUEMILANOVE ARDUINO PROTOTYPING ARDUINO LCD-KEYPAD ARDUINO GRAPGIC LCD SHIELD SHIELD SHIELD ARDUINO INPUT SHIELD ARDUINO 2-AMP MOTOR ARDUINO-XBEE SHIELD SKXBEE DRIVER SHIELD RESISTOR BREADBOARD POTENTIALMETER LEDS IR DISTANCE SENSOR PIEZO BUZZER LM35 TEMPRETURE SENSOR ULTRASONIS RANGE FINDER EZ1 SPG10 MICRO METAL RC SREVO MOTOR JUMPER WIRES DC POWER SUPPLY GEARMOTOR Page 6 ROBOT . HEAD to TOE FUN & LEARNING WITH ARDUINO PROJECTS OVERVIEW OF ARDUINO DUEMILANOVE Analog Input Pins 6 DC Current per I/O 40 mA Pin DC Current for 3.3V 50 mA Pin 16 KB (ATmega168) or 32 KB Flash Memory (ATmega328) of which 2 KB used by bootloader 1 KB (ATmega168) or 2 KB SRAM (ATmega328) 512 bytes (ATmega168) or 1 KB The Arduino Duemilanove ("2009") is a EEPROM (ATmega328) microcontroller board based on the Atmega168 Clock Speed 16 MHz (datasheet) or ATmega328(datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal POWER oscillator, a USB connection, a power jack, an ICSP The Arduino Duemilanove can be powered via the header, and a reset button. It contains everything USB connection or with an external power supply. needed to support the microcontroller; simply The power source is selected automatically. connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter "Duemilanove" means 2009 in Italian and is named can be connected by plugging a 2.1mm center- after the year of its release. The Duemilanove is the positive plug into the board's power jack. Leads from latest in a series of USB Arduino boards; for a a battery can be inserted in the Gnd and Vin pin comparison with previous versions, see the index of headers of the POWER connector. Arduino boards. The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the SUMMARY 5V pin may supply less than five volts and the board Microcontroller ATmega168 may be unstable. If using more than 12V, the voltage Operating Voltage 5V regulator may overheat and damage the board. The Input Voltage recommended range is 7 to 12 volts. 7-12V (recommended) Input Voltage The power pins are as follows: 6-20V (limits) • VIN. The input voltage to the Arduino board 14 (of which 6 provide PWM when it's using an external power source (as Digital I/O Pins output) opposed to 5 volts from the USB connection or other regulated power source). You can Page 7 ROBOT . HEAD to TOE FUN & LEARNING WITH ARDUINO PROJECTS supply voltage through this pin, or, if • SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). supplying voltage via the power jack, access These pins support SPI communication using it through this pin. the SPI library. • 5V. The regulated power supply used to • LED: 13. There is a built-in LED connected to power the microcontroller and other digital pin 13. When the pin is HIGH value, components on the board. This can come the LED is on, when the pin is LOW, it's off. either from VIN via an on-board regulator, or be supplied by USB or another regulated 5V The Duemilanove has 6 analog inputs, each of which supply. provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 • 3V3. A 3.3 volt supply generated by the on- volts, though is it possible to change the upper end board FTDI chip. Maximum current draw is of their range using the AREF pin and the 50 mA. analogReference() function. Additionally, some pins have specialized functionality: • GND. Ground pins. • I2C: analog input pins A4 (SDA) and A5 (SCL). INPUT OUTPUT Support I2C (TWI) communication using the Each of the 14 digital pins on the Duemilanove can Wire library. be used as an input or output, using pinMode(), digitalWrite(), anddigitalRead() functions. They There are a couple of other pins on the board: operate at 5 volts. Each pin can provide or receive a • AREF. Reference voltage for the analog maximum of 40 mA and has an internal pull-up inputs. Used with analogReference(). resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions: • Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset • Serial: 0 (RX) and 1 (TX). Used to receive (RX) button to shields which block the one on the and transmit (TX) TTL serial data. These pins board. are connected to the corresponding pins of the FTDI USB-to-TTL Serial chip. • External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details. • PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function. Page 8 ROBOT . HEAD to TOE FUN & LEARNING WITH ARDUINO PROJECTS THE ARDUINO IDE SETUP GETTING STARTED To start create a project, you may required to double For coming project, we are going to use Arduino IDE click the arduino.exe which the icon is to develop and upload the code to the Arduino like the figure beside. This will allow Duemilanove. The Arduino IDE are supported to you to open the Arduino IDE. Window, Mac OS X and also Linux. Be sure to get the one who is suitable to your current using OS. To get this software, please click here. Next step, you may need to choose the Arduino board using for the 1st time such as figure below. Go to Tools > Board > Arduinio Duemilanove or Nano ARDUINO IDE INSTALLATION w/ATmega 328 For Arduino software, installation are no needed. All we have to do is download and extract it out and save it anywhere you like. Next, get yourself an USB-B type cable then plug in to the Arduino while the other end connect to the PC. Lastly, you may also choose the COM port for Arduino Duemilanove. Same step as above, go to Tools > Serial Port > COM4 (Depend on the PC). INSTALL THE USB DRIVERS To make your Arduino Duemilanove start talking, you need to install the USB driver which is located inside the Arduino IDE you download (drivers/FTDI USB Drivers) Double click this icon and the installation will executing. After that, your PC/Laptop will be automatically detected the driver install and your Arduino Duemilanove are free to use. Page 9 ROBOT . HEAD to TOE FUN & LEARNING WITH ARDUINO PROJECTS THE ARDUINO IDE When you open open up the Arduino IDE, it will look On the other hand, Arduino IDE also have prepare similar to the figure above and it may be slightly lots of example for user to refer the basic of the different to those who are using Mac OS or Linux but operating code. By clicking File > Example, there was the main function of this IDE are still the same. lots of sample program to be explore. Above there was a Toolbar which consist of 7 item which is which is start from the left (compile , stop, new, open, save, upload and serial monitor). Page 10
Description: