Arduino Traffic Light Project Explanation
Traffic Light Programming with Arduino IDE (for Basic School Students)
Introduction
Hey there, young techies! Imagine standing at a busy road, waiting to cross. You see the red light
come on - cars stop. Then the yellow light warns that cars should get ready to move. Finally, the
green light tells cars to GO!
Wouldn't it be cool to make your own traffic light? Today, we'll learn how to make one using Arduino.
Think of it like becoming a traffic boss, controlling how cars move!
What You Need:
1. Arduino Uno board - The brain of our traffic light.
2. Breadboard - A board to connect all the parts without soldering.
3. 3 LEDs (Red, Yellow, Green) - To represent the traffic lights.
4. 3 Resistors (220 ohms each) - To protect the LEDs from burning out.
5. Jumper Wires - To connect everything.
6. USB Cable - To connect the Arduino to your computer.
Traffic Light Code:
// Traffic Light Program
int redLight = 8;
int yellowLight = 7;
int greenLight = 6;
void setup() {
pinMode(redLight, OUTPUT);
pinMode(yellowLight, OUTPUT);
pinMode(greenLight, OUTPUT);
}
void loop() {
digitalWrite(redLight, HIGH);
digitalWrite(yellowLight, LOW);
digitalWrite(greenLight, LOW);
delay(5000);
digitalWrite(redLight, LOW);
digitalWrite(yellowLight, HIGH);
digitalWrite(greenLight, LOW);
delay(2000);
digitalWrite(redLight, LOW);
digitalWrite(yellowLight, LOW);
digitalWrite(greenLight, HIGH);
delay(5000);
}
Terminologies in the Code:
1. Comments (//) - Used to explain the code, ignored by the computer.
2. Declaring Variables (int) - Stores integer values.
3. setup() Function - Runs once when the Arduino is powered on.
4. pinMode() Function - Sets a pin as INPUT or OUTPUT.
5. loop() Function - Repeats the code continuously.
6. digitalWrite() Function - Turns a pin HIGH (ON) or LOW (OFF).
7. delay() Function - Pauses the program for a specific time.
8. void Keyword - Used when a function does not return a value.
9. Curly Braces ({}) - Group code statements together.
10. Semicolon (;) - Marks the end of a statement.
11. High and Low States (HIGH, LOW) - Represent ON and OFF signals.
Why These Terms Matter:
Understanding these terms is like knowing the rules of a game. Once you know them, you can build
cool projects like robots or smart systems!
Got more questions or want to build something else? Let me know!