Arduino "Getting Started" Tutorial: Hardware
Arduino "Getting Started" Tutorial: Hardware
Undergraduate Program
Handout: Arduino Tutorial Getting Started
What is Arduino?
The Arduino is a sophisticated single-board computer that can be programmed to sense and control the
physical world around us. It can be used as a dedicated computer for industrial automation or to control a
robot. It can take input from a variety of sensors connected to its input pins. It can process the information
locally or can send data to another computer for remote computation. The processed information can then
be used to make decisions and/or control motors or other actuators connected to the boards output pins.
Hardware
The processing unit on the Arduino is the ATmega328 microcontroller integrated circuit. It uses input and
output ports/pins to communicate with the outside world. Some of the microcontrollers inputs and outputs
are connected to peripherals and other electronic components on the board itself, and others are available
for use as sensor inputs or output to other devices. The microcontroller can be programmed using an open
source programming platform based on the C programming language and a wiring language that is very
easy to use.
(a) Front
(b) Back
Microcontroller
Operating Voltage
Input Voltage (recommended)
Input Voltage (limits)
Digital I/O Pins
Analog Input Pins
DC Current per I/O Pin
DC Current for 3.3V Pin
Flash Memory
SRAM
EEPROM
Clock Speed
ATmega328
5V
712V
620V
14 (of which 6 provide PWM output)
6
40 mA
50 mA
32 KB (ATmega328) of which 0.5 KB is used by the bootloader
2 KB (ATmega328)
1 KB (ATmega328)
16 MHz
Powering the Arduino Board The board can be powered through the USB connector or through an
external power supply. USB power is sufficient for blinking LEDS and other applications where the total
current required is small. For the external power supply, you can use a battery, an AC-DC adapter with an
appropriate output voltage, or a desktop power supply. The power pins on the board are:
VIN: The input voltage pin for Arduino for external power source. You can supply voltage through
this pin, or, if supplying voltage via the power jack, access it through this pin.
5V: This pin outputs a regulated 5V from the regulator on the board. The board can be supplied
with power either from the DC power jack (712V), the USB connector (5V), or the VIN pin of the
board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your
board. Generally, you should not wire a battery or power supply directly to this pin!
3V3: A 3.3V supply generated by the on-board regulator. Maximum current draw is 50 mA.
GND: The ground pin or the negative terminal of your board.
Input and Output: There are 14 digital pins/ports on the Arduino UNO. They all operate at 5V and
can be used for input or output. Each pin can give or receive approximately 40mA of current. There are 6
analog input pins/ports, labeled A0 through A5. Each analog input pin provides 10 bits of resolution (i.e.
1024 different values). By default they measure from ground to 5 volts.
Some of the pins on Arduino UNO board can also be used for other specialized function.
Serial: pin-0 and pin-1 can be configured to be used receiving and transmitting serial data to peripheral
device or computer.
External Interrupts: pin-2 and pin-3 can configured as external interrupt.
PWM: pin-3, pin-5, pin-6, pin-9, pin-10, pin-11 can be configured as Pulse width modulation (PWM)
outputs.
SPI: pin-10 (SS), pin-11 (MOSI), pin-12 (MISO), pin-13 (SCK) pins can be configured for serial
communication using SPI protocol.
LED: An SMD-LED is connected to pin-13 of the C. When the pin has logic-high, the LED is on,
and when it is logic-low it is off.
TWI: pin-A4 (SDA) and pin-A5 (SCL) pin support TWI communication.
Software
The Arduino Uno can be programmed with the open-source Arduino software. The programming platform
enables you to write and edit your program in wiring-language. It can cross compile your code for ATmega328.
It can also upload your program using the same software.
The C on the Arduino UNO comes with a pre-burned boot-loader, which allows to upload new code
to it without the use of an external hardware programmer. Instead of using a physical Reset button the
Arduino Uno is designed in a way that allows it to be reset by software running on a connected computer.
The Arduino programs can be categorized in 3 parts,structure, values and functions. For details on
programming please refer to http://arduino.cc/en/Reference/HomePage. The basic structure of the
programming language is simple. It will always contain 2 parts/functions, one is the setup() function,
which is the preparation part. The other is the loop() function which is the execution part. Therefore a
simple sketch of your program will look like as:
void setup()
{
\\statements here
}
void loop()
{
\\statements here
}
Figure 2: Equipment and Components Required, reprinted from Beginning to Android with Arduino
You can connect the circuit as shown in the Figure 4a,4b. You can see that the LED is connected to
pin-13 and to ground via 220 resistor. The resistor is there to control the current in the LED. Now, you
are ready to write your code to program ATmega328.
Referring to the installation of the Arduino software, once you run the shell script in Ubuntu or the open
the executable in Windows, you will see the Arduino IDE as shown in the Figure 5.
The Blinking LED program is part of the public domain examples program as given on th arduino
website. You can directly open the program from menu on the top left corner by following the hierarchy,
File-Examples-Basics-Blink. A program will be opened in a separate window and will look like as follows:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH);
// turn the LED on (HIGH is the voltage level)
delay(1000);
// wait for a second
digitalWrite(led, LOW);
// turn the LED off by making the voltage LOW
delay(1000);
// wait for a second
}
Press cntrl-R to compile the code. If there is no errors, then press cntrl-U to upload the compiled
program on your C Flash memory. As told earlier, once the program is uploaded successfully, the board
will automatically get a reset and after a few second will start blinking your LED.
Exercise
Now, the next assignment is to implement a digital switch using the board.
We need 1 digital on-off switch and 1- 10 resistor and some more connecting wires.
We will also make use of the 5V input pin of the board and pin-2 as digital input pin.
References
http://arduino.cc.
http://arduino.cc/en/Main/ArduinoBoardUno.
http://arduino.cc/en/Guide/Introduction.
www.atmel.com/Images/doc8161.pdf.
Arduino Programming Notebook by - by Brian W. Evans.
Beginning Android ADK with Arduino by Mario Bohmer
http://arduino.cc/en/Tutorial/Button
http://arduino.cc/en/Tutorial/Blink