Lesson 1
The Arduino board
Topics:
The Arduino
Digital IO
Analog IO
Setup
• Go to
http://arduino.cc/en/Guide/HomePage
1. Download & install the Arduino
environment (IDE)
Meet Arduino Uno
Arduino
What and Why?
• https://www.youtube.com/watch?v=CSx6k-zX
lLE&t=1s
Meet Arduino Uno
PWR IN USB
(to Computer)
RESET
SCL\SDA
(I2C Bus)
POWER
5V / 3.3V /
GND
Digital I\O
PWM(3, 5, 6, 9, 10,
11)
Analog
INPUTS
Getting Started
1. Connect the board to your
computer via the USB cable
2. If needed, install the drivers
on page 8
3. Launch the Arduino IDE
4. Select your board
5. Select your serial port
Select Serial Port and Board
What if the Port is Greyed
out?
Click on the url below and
Follow the steps. Ask your IT
Technician to assist if needed.
USB Drivers for Com P
orts
Arduino IDE
See: http://arduino.cc/en/Guide/Environment for more information
BIG 6 CONCEPTS
digitalWrite()
analogWrite()
digitalRead()
if() statements /
Boolean
analogRead()
Serial communication
This work is licensed under a
Creative Commons Attribution-ShareAlike 3.0 United States License.
Arduino Digital I/0
pinMode(pin, mode)
Sets pin to either INPUT or OUTPUT
digitalRead(pin)
Reads HIGH or LOW from a pin
digitalWrite(pin, value)
Writes HIGH or LOW to a pin
Concepts: INPUT vs.
OUTPUT
Referenced from the perspective of the
microcontroller (electrical board).
Inputs is a signal / Output is any
information going signal exiting the
into the board. board.
Examples: Examples: LEDs,
Buttons Switches, DC motor, servo
Light Sensors, motor, a piezo
Flex Sensors, buzzer, relay, an
Humidity Sensors, RGB LED
Temperature
Sensors…
Arduino
Integrated Development Environment (IDE)
Two required functions
/ methods / routines:
void setup()
{
// runs once
}
void loop()
{
// repeats
error & status messages }
PinMode
• A pin on arduino can be set as input or
output by using pinMode function.
• pinMode(13, OUTPUT); // sets pin 13 as
output pin
• pinMode(13, INPUT); // sets pin 13 as input
pin
Reading/writing digital
values
digitalWrite(13, LOW);
// Makes the output voltage on pin 13 ,
0V
digitalWrite(13, HIGH);
// Makes the output voltage on pin 13 ,
5V
delay(1000);
// time for previous command is 1000
ms
Comments, Comments,
Comments
Comments are for you – the programmer and
your friends…or anyone else human that might
read your code.
// this is for single line comments
// it’s good to put a description at the
top and before anything ‘tricky’
/* this is for multi-line comments
Like this…
And this….
*/
comments
Our First Program
Open your Arduino IDE
Go to:
File>Basics>Blink and Enter (see pic
below)
You can delete the first 25 rows. It is just
comments.
Your program should look like the pic below
Connect your Arduino board to your computer and
hit the “Verify” button
If it compiles in the bottom right corner
You can upload it on your computer
Explanation of Program
Blinking LED Code.
As an Output
Function
Pin to be set
Experimenting with your Program
Change the delay in Row_10 to 5000, upload and
observe.
Change the delay in Row_12 to 3000, upload and
observe.
Change the delayRow_10 to 500, upload and observe.
Assessment
Make the LED flash on
for 4 seconds and off for
½ a second.
Congratulations!!!