Arduino Traffic Light Leson Plan
Arduino Traffic Light Leson Plan
Arduino Traffic Light Leson Plan
Arduino:
Traffic Light
A student with no experience working with circuitry and little experience working with coding learns the
fundamentals of using Arduino hardware.
Learning Objectives
At the end of the class, the student will:
Understand what a circuit is.
Be able to identify the hardware used in a circuit.
Be able to identify the similarities and differences between C++ and python (or other coding languages
you may have previously covered).
Materials
7 Arduino Uno’s
7 Breadboards
21 - 35 Resistors (I used 200 ohm resistors)
49 - 63 Jumper Wires
7 Green LEDs
7 Yellow LEDs
7 Red LEDs
7 Purple LEDs (suggested, not necessary)
7 Blue LEDs (suggested, not necessary)
7 Chromebooks.
Estimated Budget: $0 when borrowed from CTC
Room Setup
Push several tables together with chairs around them.
Charge and log into 7 Chromebooks.
Open the Chromebooks to codebender.cc and setup the website.
o You will need to add the app to Chrome. Make sure you log into the website and add the app
before class begins.
Setup each station with an Arduino Uno, a breadboard, 7 jumper wires, a red LED, A yellow LED, a
green LED, and 3 resistors.
Program Outline
The program is completed in one (120) minute session.
(5) Explain the project for today
Making a traffic light.
Made up of several circuits.
Once we have the hardware setup, then we’ll code it so the hardware knows what to do!
COMMUNITY TECHNOLOGY CENTER 08/13/2015 | sl | Page 1
10 W 14th Ave Parkway | Denver, CO 80204 | 720.865.1706 | https://denverlibrary.org/ctc
(5) Explain a circuit
+ electricity
- electricity
Explain to the students that a circuit is when we take electricity in a loop to make something happen –
like turn on a light. Use your awesome skills of an artist to draw something like this on a board:
void setup(){
pinMode(LED01,OUTPUT);
}
void loop(){
digitalWrite(LED01,HIGH);
delay(1000);
digitalWrite(LED01,LOW);
delay(1000);
}
Every sketch for Arduino will have at least these 2 functions:
o setup ( )
defines what’s happening on your board
in this case, we are saying that we are going to be pushing data/energy to whatever is
connected to LED01 (which is pin 13).
o loop ( )
you won’t keep your Arduino connected to a computer, so it needs instructions on what
to do and how to interact without you there
Click the verify code button.
Read through the errors. Help students debug problems in their script.
Most likely problems:
o Missed one or more semicolons.
o Didn’t close a function.
o Didn’t type something correctly (e.g. needed capitals instead of lowercase).
Click the upload button.
Troubleshoot any problems.
Now you should have a light on your board that turns on for one second, then off for one second. Neat!
But we want to add more LEDs to our circuit! Our ground is already used up with just one! What are we
to do!?!?!?
void setup(){
pinMode(red,OUTPUT);
pinMode(yellow,OUTPUT);
pinMode(green,OUTPUT);
}
void loop(){
digitalWrite(red,HIGH);
delay(1000);
digitalWrite(red,LOW);
delay(10);
digitalWrite(yellow,HIGH);
delay(1000);
digitalWrite(yellow,LOW);
delay(10);
digitalWrite(green,HIGH);
delay(1000);
digitalWrite(green,LOW);
delay(10);
Walk around the room and assist students who are struggling.
Most common problems:
o LED turned the wrong way
o Circuit not grounded
o Problems with code (listed above)
Instructor’s Notes
COMMUNITY TECHNOLOGY CENTER 08/13/2015 | sl | Page 5
10 W 14th Ave Parkway | Denver, CO 80204 | 720.865.1706 | https://denverlibrary.org/ctc
1. We use Chromebooks. If you use laptops instead, download and install the Arduino software on each of
your computers. Link below.
Links
Learning Arduino coding vocabulary: https://www.arduino.cc/en/Reference/HomePage
Arduino software: https://www.arduino.cc/en/Main/Software
Explanation of Arduino by Make: https://www.youtube.com/watch?v=CqrQmQqpHXc