0% found this document useful (0 votes)
18 views21 pages

GR 7 Robotics - Lesson 6 - Intro To Arduino and Blink

Uploaded by

tshegomabunda12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views21 pages

GR 7 Robotics - Lesson 6 - Intro To Arduino and Blink

Uploaded by

tshegomabunda12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Lesson 6

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
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
Meet Arduino Uno
Arduino
What and Why?
• https://www.youtube.com/watch?v=CSx6k-
zXlLE&t=1s
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

USB Drivers for Com Ports


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 signal


information going into exiting the board.
the board.

Examples: Buttons Examples: LEDs, DC


Switches, Light motor, servo motor, a
Sensors, Flex piezo buzzer, relay,
Sensors, Humidity an RGB LED
Sensors,
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 tp 500, upload and observe.

You might also like