0% found this document useful (0 votes)
6 views

Arduino Traffic Light Project

The document describes a project for an Arduino-based traffic light system that includes signals for cars and a pedestrian crossing light. It outlines the components used, circuit design, code implementation, and the working mechanism of the system, which ensures pedestrian safety while managing traffic flow. The project serves as a demonstration of a smart traffic light system that operates based on button inputs for both vehicles and pedestrians.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Arduino Traffic Light Project

The document describes a project for an Arduino-based traffic light system that includes signals for cars and a pedestrian crossing light. It outlines the components used, circuit design, code implementation, and the working mechanism of the system, which ensures pedestrian safety while managing traffic flow. The project serves as a demonstration of a smart traffic light system that operates based on button inputs for both vehicles and pedestrians.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Future University In Egypt

Faculty of Computer And Information Technology

Computer Science Department

Traffic Light

Name ID
Yousef Mohamed 20212812
Karim Magdy 20210304
Maryam Ayman 20213997
Gehad Osama 20212176
Youssef Yasser 20213360
Mohammed Hazem 20213913
Arduino Traffic Light System with Pedestrian Crossing

1. Introduction
This project implements a traffic light system using an Arduino Uno. It includes two traffic
lights for cars and one pedestrian crossing light. The system operates under normal
conditions where cars move, and pedestrians wait until a button is pressed to request a
crossing.

2. Components Used
- 1 × Arduino Uno

- 6 × Red LEDs (Traffic Light Signals)

- 6 × Yellow LEDs (Transition Signals)

- 6 × Green LEDs (Go Signals)

- 2 × Push Buttons (One for cars, one for pedestrians)

- 12 × Resistors (220Ω) for LEDs

- Jumper Wires

- 1 × Breadboard

3. Circuit Design
The circuit consists of:
- Two traffic light signals (TC1 & TC3) with Red, Yellow, and Green LEDs.
- A pedestrian light (TH2) with Red, Yellow, and Green LEDs.
- Two buttons:
- **Button 1 (Car Button)** controls traffic signals.
- **Button 2 (Pedestrian Button)** allows pedestrians to cross.

When Button 2 is pressed, the traffic lights transition safely, stopping vehicles and allowing
pedestrians to cross. Afterward, normal traffic resumes.

4. Code Implementation
The Arduino code controls the system based on button inputs and LED signals.

Code:

void setup() {
// Traffic Light 1 (TC1)
pinMode(8, OUTPUT); // Red LED TC1
pinMode(9, OUTPUT); // Yellow LED TC1
pinMode(10, OUTPUT); // Green LED TC1
// Traffic Light 2 (TC3)
pinMode(11, OUTPUT); // Red LED TC3
pinMode(12, OUTPUT); // Yellow LED TC3
pinMode(13, OUTPUT); // Green LED TC3

// Pedestrian Traffic Light (TH2)


pinMode(7, OUTPUT); // Red LED TH2
pinMode(6, OUTPUT); // Yellow LED TH2
pinMode(5, OUTPUT); // Green LED TH2

// Buttons
pinMode(4, INPUT_PULLUP); // Button 1 (Car Button)
pinMode(3, INPUT_PULLUP); // Button 2 (Pedestrian Button)

Serial.begin(9600);

// Set default state: Cars moving, Pedestrians stopped


normalTraffic();
}

void loop() {
int button1 = digitalRead(4); // Read Car Button
int button2 = digitalRead(3); // Read Pedestrian Button

Serial.print("Button 1: ");
Serial.print(button1);
Serial.print(" | Button 2: ");
Serial.println(button2);

if (button1 == LOW || button2 == LOW) {


changeTraffic();
normalTraffic(); // Return to normal state after pedestrian crossing
}
}

void normalTraffic() {
// Cars move, Pedestrians stop
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH); // Green TC1

digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH); // Green TC3

digitalWrite(7, HIGH); // Red TH2 (Pedestrians stop)


digitalWrite(6, LOW);
digitalWrite(5, LOW);
}

void changeTraffic() {
// Yellow transition for safety
digitalWrite(10, LOW);
digitalWrite(9, HIGH); // Yellow TC1

digitalWrite(13, LOW);
digitalWrite(12, HIGH); // Yellow TC3

digitalWrite(7, LOW);
digitalWrite(6, HIGH); // Yellow TH2

delay(3000); // Transition delay

// Stop cars, allow pedestrians


digitalWrite(9, LOW);
digitalWrite(8, HIGH); // Red TC1

digitalWrite(12, LOW);
digitalWrite(11, HIGH); // Red TC3

digitalWrite(6, LOW);
digitalWrite(5, HIGH); // Green TH2 (Pedestrians walk)

delay(10000); // Pedestrian crossing time


}

5. Working Mechanism
- **Default State**: Cars move (green light), Pedestrians wait (red light).
- **Button Pressed**:
- The system transitions using yellow lights.
- Cars stop (red light), and pedestrians cross (green light).
- After the crossing duration, normal traffic resumes.
6. Conclusion
This project demonstrates a simple yet effective **smart traffic light system** using an
Arduino. It ensures safety for pedestrians while maintaining smooth traffic flow.

You might also like