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

G2 CPP110 Arduino Traffic Light Design 10-11-24

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

G2 CPP110 Arduino Traffic Light Design 10-11-24

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Republic of the Philippines

University of Cabuyao
(Pamantasan ng Cabuyao)
College of Engineering
Katapatan Mutual Homes, Brgy. Banay-banay, City of Cabuyao, Laguna, Philippines 4025

Course: CPP110 Activity: Arduino Traffic Light Design


Group Members: Section: 3CPE-A
Aldueza, Mark Levi Group No: 2
Cinco, Iean Mike Date Submitted: October 11, 2024
Dueñas, Kyla Mae
Enraca, Ma. Camille
Gelvero, Ma. Sophia
Obcemia, Uriel Genesis
Padua, Cedie James
Vidad, John Markdyl
1. Circuit Design
Republic of the Philippines
University of Cabuyao
(Pamantasan ng Cabuyao)
College of Engineering
Katapatan Mutual Homes, Brgy. Banay-banay, City of Cabuyao, Laguna, Philippines 4025

2. Circuit Schematic

3. Component List
Republic of the Philippines
University of Cabuyao
(Pamantasan ng Cabuyao)
College of Engineering
Katapatan Mutual Homes, Brgy. Banay-banay, City of Cabuyao, Laguna, Philippines 4025

4. Code

// Declare LED pins


int redLED = 13;
int yellowLED = 12;
int greenLED = 11;

// Declare Button pin


int buttonPin = 2; // Pin for the pedestrian button
int buttonState = 0;

void setup() {
// Setting the LED pins to OUTPUT
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);

//Turn off LEDs


digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(redLED, LOW);

// Setting the Button pins to INPUT_PULLUP


pinMode(buttonPin, INPUT);

// For the serial monitor


Serial.begin(9600);
}

void loop() {
digitalWrite(greenLED, HIGH);
Serial.println("GREEN");
greenLight();
digitalWrite(greenLED, LOW);

digitalWrite(yellowLED, HIGH);
Serial.println("YELLOW");
delay(2000);
digitalWrite(yellowLED, LOW);

digitalWrite(redLED, HIGH);
Serial.println("RED");
redLight(5);
digitalWrite(redLED, LOW);

digitalWrite(yellowLED, HIGH);
Serial.println("YELLOW");
delay(2000);
digitalWrite(yellowLED, LOW);
}

void greenLight() {
for (int i = 1; i < 11; i++){
buttonState = digitalRead(buttonPin);

if (buttonState == 0){
Serial.println(i);
delay(1000);
}
Republic of the Philippines
University of Cabuyao
(Pamantasan ng Cabuyao)
College of Engineering
Katapatan Mutual Homes, Brgy. Banay-banay, City of Cabuyao, Laguna, Philippines 4025

else if (buttonState == 1){


Serial.println("PEDESTRIAN CROSSING");
delay(2000);
pedestrian();
}
}
}

void redLight(int j) {
for (int i = 1; i < j+1; i++){
Serial.println(i);
delay(1000);
}
}

void pedestrian(){
digitalWrite(yellowLED, HIGH);
Serial.println("YELLOW");
delay(2000);
digitalWrite(yellowLED, LOW);

digitalWrite(redLED, HIGH);
Serial.println("RED");
redLight(10);
digitalWrite(redLED, LOW);

digitalWrite(yellowLED, HIGH);
Serial.println("YELLOW");
delay(2000);
digitalWrite(yellowLED, LOW);

loop();
}

5. Reflection
- How does timing affect the behavior of traffic lights.

Proper timing of traffic lights helps to keep cars moving efficiently, reduces waiting time, cuts down
on fuel use, and improves safety for both drivers and pedestrians. For instance, if the total time it
takes for a traffic light to go through its entire sequence (red, yellow, green) is too long, drivers may
have to wait for too long, leading to frustration. And if it’s too short, drivers may not have enough
time to get through intersection, causing backups.

- What challenges did you face while connecting multiple LEDs, and how did you solve them?

Wiring multiple LEDs is much simpler than programming multiple LEDs in Arduino. Errors in the
code can happen, leading to the circuit not functioning as intended. But we’ve solved it by writing
and debugging the code incrementally. Starting with single LED and then progressing to more
complex sequences.

- How would you improve this system for a more complex traffic scenario?

We could improve it by adding adaptive signal control. This system can change the timing to better
handle current traffic conditions, reducing wait times and improving flow. We could also add an
intersection type and configuration.

6. Output
https://drive.google.com/drive/folders/1MBsKrZks5YYMmEDMEg6QUA9aor8V_P-K?usp=sharing

You might also like