1 Arduino 23
1 Arduino 23
What is a Development
Board
A printed circuit
board designed to
facilitate work
with a particular
microcontroller.
I2C
POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)
Analog
INPUTS
Making-robots-with-arduino.pdf
UNO
LEONARDO
DUE
YUN
TRE
ZERO
MICRO
ESPLORA
& many more
Sample Specification:
Arduino Uno
Microcontroller:
AT mega 328
Operating Voltage
5V
Input Voltage (recommended) 7-12V
Input Voltage (limits)
6-20V
Digital I/O Pins
14 (of which 6 provide PWM output)
Analog Input Pins
6
DC Current per I/O Pin
40 mA
DC Current for 3.3V Pin
50 mA
Flash Memory
32 KB (of which 0.5 KB used by boot loader)
SRAM
2 KB (ATmega328)
EEPROM
1 KB (ATmega328)
Clock Speed
16 MHz
todbot.com/blog/bionicarduino
Getting Started
Check out: http://arduino.cc/en/Guide/HomePage
1. Download & install the Arduino environment
(IDE)
2. Connect the board to your computer via the
UBS cable
3. If needed, install the drivers (not needed in lab)
4. Launch the Arduino IDE
5. Select your board
6. Select your serial port
7. Open the blink example
8. Upload the program
Arduino IDE
C
O
M
P
I
L
E
U
P
L
O
A
D
N
E
W
O
P
E
N
S
A
V
E
Status Messages
todbot.com/blog/bionicarduino
Code is case
sensitive
Statements are
commands and
must end with a
semi-colon
Comments
follow a // or
begin with /*
and end with */
loop and setup
Terminology
Digital I/0
www.mikroe.com/chapters/view/1
pinMode(pin, mode)
digitalRead(pin)
digitalWrite(pin, value)
Writes HIGH or LOW to a pin
Electronic stuff
Arduino Timing
delay(ms)
Pauses for a few milliseconds
delayMicroseconds(us)
Pauses for a few microseconds
More commands:
arduino.cc/en/Reference/
HomePage
Variables
Basic variable types:
Boolean
Integer
Character
Declaring Variables
Boolean: boolean
variableName;
Integer: int variableName;
Character: char
variableName;
String: stringName [ ];
Assigning Variables
Boolean: variableName =
true;
or variableName = false;
Integer: variableName =
32767;
or variableName = -32768;
Character: variableName =
A;
Variable Scope
Where you declare your variables
matters
Setup
void setup ( ) { }
If Statements
if ( this is true ) { do this; }
If
if ( this is true ) { do this; }
Conditional
if ( this is true ) { do this; }
Action
if ( this is true ) { do this; }
Else
else { do this; }
Basic Repetition
loop
For
while
Basic Repetition
void loop ( ) { }
Basic Repetition
void loop ( ) { }
Basic Repetition
void loop ( ) { }
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
//this could be anything
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
while ( count<10 )
{
//while action code goes here
//should include a way to change count
//variable so the computer is not stuck
//inside the while loop forever
}
Basic Repetition
while ( count<10 )
{
//looks basically like a for loop
//except the variable is declared before
//and incremented inside the while
//loop
}