The document outlines the components needed to build a traffic light simulation using an Arduino Uno, including LEDs and resistors. It describes the sequence of operations for the traffic light, detailing how to set the digital pins for each light and the timing for each color. The provided code snippet illustrates the setup and loop functions for controlling the lights in the correct order.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
6 views6 pages
Arduino Traffic Lights
The document outlines the components needed to build a traffic light simulation using an Arduino Uno, including LEDs and resistors. It describes the sequence of operations for the traffic light, detailing how to set the digital pins for each light and the timing for each color. The provided code snippet illustrates the setup and loop functions for controlling the lights in the correct order.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6
You will need the following
parts
1x Arduino Uno 1x USB Cable 1x Breadboard 4x Jumper Wire 1x Red LED 1x Yellow LED 1x Green LED 3x Resistors How does it work?
Think of how a traffic light works.
it starts from RED
then turns to GREEN then turns YELLOW and back to RED we connected DIGITAL PIN 7 (D7) to the RED light we connect DIGITAL PIN 6 (D6) to the YELLOW light we connect set D7 to HIGH (red light) set D6 to LOW (yellow light) set D5 to LOW (green light) WAIT for 10 seconds set D7 to LOW (red light) set D6 to LOW (yellow light) set D5 to HIGH (green light) WAIT for 10 seconds set D7 to LOW (red light) set D6 to HIGH (yellow light) set D5 to LOW (green light) WAIT for 1 seconds void setup() { // turn the yellow light on // turn the // initialize red together with red yellow light on light pin digitalWrite(13, HIGH); digitalWrite(13, pinMode(13, digitalWrite(12, HIGH); LOW); OUTPUT); digitalWrite(11, LOW); digitalWrite(12, // initialize // wait HIGH); yellow light pin delay(1000); digitalWrite(11, pinMode(12, LOW); OUTPUT); // turn the green light on // wait // initialize green digitalWrite(13, LOW); delay(1000); light pin digitalWrite(12, LOW); pinMode(11, digitalWrite(11, HIGH); //start over OUTPUT); // wait } } delay(5000); void loop() {