Traffic lights using Arduino
In this post, we will design an Arduino based traffic lights control system that switches the lights at different time intervals.
Introduction-
We are going to use Arduino to control three different LEDs on a different time interval.
Components required -
1. Arduino board
2. LEDs ( red, yellow and green)
3. 220ohm resistors - 3
4. Breadboard and connection wires.
Connections-
1. Connect the +ve of Red LED to pin 5 of Arduino and -ve to GND.
2. Connect the +ve of Yellow LED to pin 6 of Arduino and -ve to GND.
3. Connect the +ve of Green LED to pin 7 of Arduino and -ve to GND.
Circuit schematic-
Arduino code -
void setup() { pinMode(5,OUTPUT); pinMode(6,OUTPUT); pinMode(7,OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(5, HIGH); delay(2000); digitalWrite(5, LOW); delay(200); digitalWrite(6, HIGH); delay(1000); digitalWrite(6, LOW); delay(100); digitalWrite(7, HIGH); delay(2000); digitalWrite(7,LOW); delay(100); }
No comments