Getting Started With Arduino
Getting Started With Arduino
Getting Started With Arduino
1.1 Introduction
In 2005, Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and
David Mellis came up with an idea for an easy-to-use programmable device for
interactive art design projects at the Interaction Design Institute Ivrea in Ivrea, Italy.
The device needed to be simple, easy to connect to various things (such as relays,
motors, and sensors), and easy to program. It also needed to be inexpensive to make
it cost-effective for students and artists. They selected an AVR family of 8-bit
microcontroller (MCU or µC) devices from Atmel and designed a self-contained
circuit board with easy-to-use connections, wrote bootloader firmware for the
microcontroller, and integrated it all into a simple development environment that
used programs called “sketches.” The result was Arduino.
Arduino is an open-source microcontroller that enables programming and
interaction; it is programmed in C/C++ with an Arduino library to allow it to access
the hardware. This allows for more flexible programmability and the ability to use
electronics that can interface with Arduino. Because Arduino is open source, the
plans for the circuits are available online for free to anyone who wants to use and
create their own board based on the schematics, as long as they share what they
create. This allows for considerable customizability in projects; till date, users have
built Arduinos of different sizes, shapes, and power levels to control their projects.
Arduino is composed of two major parts:
1. The Arduino board, which is a piece of hardware you work on when you build
your objects.
2. The Arduino IDE, which is a piece of software you run on your computer. You
use the IDE to create a sketch (a small computer program) that you upload to the
Arduino board.
Arduino is different from other platforms in the market because of the following
features:
Interrupt 1
Interrupt 0
(SPI)MISO
(SPI)MOSI
(I2C)SCL
(I2C)SDA
In-circuit Serial
(SPI)SCK
(SPI)SS
Programmer for USB Serial Out (TX)
interface Serial In (RX)
Reset Button
In-circuit Serial
USB to Programmer for
Computer Atmega328
MISO VCC
SCK MOSI
/RESET GND
7-12V DC
Input
(I2C)SDA
(I2C)SCL
Reset
Ground
3.3V Power
5V Power Voltage
In
Analog In
The Arduino Uno pinout is printed in the silkscreen in the top section. While this
pinout is a good start, it is not a comprehensive guide. At first, you mainly use the
pins in the female headers at the edge of the board (top and bottom in the photo), as
well as the USB, and maybe the power
Tx and Rx are serial UART pins used for RS-232 and USB communications
I2C is another serial communications method that uses a bidirectional data line
(SDA) and a clock line (SCL)
SPI is another serial communications method that uses one line for the master to
transmit (MOSI—Master Out Slave In), another for the master to receive (MISO),
and a third as a clock (SCK)
A/D, the Analog to Digital input, converts an analog voltage into a digital
representation
PWM (Pulse Width Modulator) is used to create a square wave with a specific duty
cycle (high time vs low time)
ICSP is the In Circuit Serial Programming—another way to program the processor
Vcc is the voltage supplied to the processor (+5VDC regulated from a higher input
voltage)
3.3VDC is a regulated voltage (from the higher input voltage) for peripherals
requiring that voltage—50 mA maximum
1.2 Arduino Variants 7
IOREF provides a voltage reference so shields can select the proper power source
AREF is a reference INPUT voltage used by the A/Ds
GND is the ground reference
RESET resets the processor (and some peripherals)
2. DFRobot RoMeo BLE
The DFRobot Romeo BLE All-in-one Microcontroller (ATMega 328) is an
all-in-one Arduino-compatible microcontroller specifically designed for robotic
applications. It benefits from the Arduino open-source platform; it is supported by
thousands of open-source codes, and can easily be expanded with your
Arduino-compatible shields.
This robot controller uses an Atmel ATmega328p as the main microcontroller. It
comes preprogrammed with an Arduino bootloader for compatibility with the
user-friendly Arduino Uno platform.
A secondary Texas Instruments CC2540 microcontroller handles the BLE
Bluetooth Low Energy communication services. It comes preprogrammed with a
firmware that supports transparent serial over Bluetooth and an AT command
interpreter. Both microcontrollers are full programmable.
The Romeo robot controller contains a built in L298 dual channel motor driver
chip. This motor driver can be used to drive two 5–23 V DC motors at up to 2
amps. Screw terminals are provided for connecting two motors and an external
motor power supply.
8 1 Getting Started with Arduino
The Romeo BLE microcontroller board also has a large number of pin headers to
simplify connections to your robot project. A full set of 3-pin analog and digital
GPIO headers provide access to signal, voltage, and ground lines at each connec-
tion to simplify wiring arrangements. The digital GPIO headers can also be used to
drive servos and a screw terminal can provide an external servo power supply.
A full set of Arduino Uno compatible headers allow you to choose from a large
number of Arduino-compatible shields for expansion. A triplet of I2C connectors is
also provided.
Additional features include five optional user push buttons, a reset button, and a
number of LED status indicators to assist with diagnostics. The optional user
buttons are conveniently wired to a single analog input. They can be enabled or
disabled via a slider switch (Fig. 1.3).
Before beginning your work, you must first download the development environ-
ment (the IDE) from here: www.arduino.cc/en/Main/Software.
1. Choose the right version for your operating system.
2. Download the file and double-click on it to open it; on Windows or Linux, this
creates a folder named Arduino-[version], such as arduino-1.0.
3. Drag the folder to wherever you want it: your desktop, your Program Files
folder (on Windows), etc. On the Mac, double-clicking it will open a disk image
with an Arduino application (drag it to your Applications folder).
4. Whenever you want to run the Arduino IDE, you will need to open up the
Arduino (Windows and Linux) or Applications folder (Mac), and double-click
the Arduino icon. Do not do this yet, though; there is one more step.
5. You must install the drivers that allow your computer to communicate with your
board through the USB port (Fig. 1.4).
10 1 Getting Started with Arduino
Plug the Arduino board into the computer; when the Found New Hardware
Wizard window comes up. The Found New Hardware Wizard will open up as
Windows will have detected that you have connected a new piece of hardware
(your DFRobot Remeo board) to your PC. Tell it NOT to connect to Windows
update (Select No, not at this time) and then click Next.
On the next page, select “Install from a list or specific location (Advanced)”
and click Next (Fig. 1.5).
Make sure that “Search for the best driver in these locations” is checked.
Uncheck “Search removable media.” Check “Include this location in the
search” and then click the Browse button. Browse to the location of the USB
drivers and then click Next (Fig. 1.6).
1.3 Install the Drivers 11
Fig. 1.6 Select “Search for the best driver in these locations”
12 1 Getting Started with Arduino
The wizard will now search for a suitable driver and then inform you that a
“USB Serial Convertor” has been found and that the hardware wizard is now
complete. Click “Finish.”
Now, you are ready to upload your first Sketch (Fig. 1.7).
The IDE is split up into the Toolbar across the top, the code, or Sketch Window in
the center and the Serial Output window at the bottom (Fig. 1.8).
The Toolbar consists of 5 buttons, underneath the Toolbar is a tab, or a set of
tabs, with the filename of the code within the tab. There is also one more button on
the far right hand side. Along the top is the file menu with drop-down menus with
the headers File, Edit, Sketch, Tools, and Help. The buttons in the Toolbar provide
convenient access to the most commonly used functions within this file menu.
The Toolbar buttons are listed above. The functions of each button are as follows
(Table 1.1):
1.4 Arduino IDE 13
Upload Open
Now, you are ready to test your first program with your Arduino board.
1. Open the Blink example sketch by going to: File ! Examples ! 01.
Basics ! Blink (Fig. 1.9).
2. Select the type of Arduino board you are using: Tools ! Board ! your board
type (Fig. 1.10).
3. Select the serial port that your Arduino is attached to: Tools ! Port ! COMxx
(Fig. 1.11).
4. If you are not sure which serial device is your Arduino, have a look at the
available ports, then unplug your Arduino and look again. The one that dis-
appeared is your Arduino.
5. With your Arduino board connected, and the Blink sketch open, press the
“Upload” button (Fig. 1.12).
6. After a second, you should see some LEDs flashing on your Arduino, followed
by the message “Done Uploading” in the status bar of the Blink sketch.
7. If everything worked, the onboard LED on your Arduino should now be
blinking! You just programmed your first Arduino!