Traffic Lights Prototype

My project is a traffic lights prototype. The main objective of the project is to show people how traffic lights work and how Arduino projects can be present in our daily lives.

based in project: https://www.makeuseof.com/tag/arduino-traffic-light-controller

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Step 1: Materials That You Need

  • 1 breadboard
  • 1 arduino
  • Male-to-male wires
  • 1 button
  • 1 resistor
  • Red, green and yellow lights

Step 2: Copy the Code Below in Arduino Platform

int red = 10;

int yellow = 9;

int green = 8;

int button = 12; // switch is on pin 12

void setup(){

pinMode(red, OUTPUT);

pinMode(yellow, OUTPUT);

pinMode(green, OUTPUT);

}

void loop() {

if (digitalRead(button) == HIGH){

delay(15); // software debounce

if (digitalRead(button) == HIGH) {

// if the switch is HIGH, ie. pushed down - change the lights! changeLights(); delay(15000);

// wait for 15 seconds

}

}

}

void changeLights(){

// green off, yellow on for 3 seconds

digitalWrite(green, LOW);

digitalWrite(yellow, HIGH);

delay(3000);

// turn off yellow, then turn red on for 5 seconds

digitalWrite(yellow, LOW);

digitalWrite(red, HIGH);

delay(5000);

// red and yellow on for 2 seconds (red is already on though)

digitalWrite(yellow, HIGH);

delay(2000);

// turn off red and yellow, then turn on green digitalWrite(yellow, LOW);

digitalWrite(red, LOW);

digitalWrite(green, HIGH);

delay(3000);

}

Step 3: Male-to-male Wires

Make sure the correct male-to-male wires are connected in the breadboard since the breadboard works in a way that all the holes in the same row are connected. Also, all the male-to-male wires need to be in the right entrance at the Arduino to the code work.

Step 4: Resistors and Button

Place the resistors and buttons connected to the male-to-male wires in the same row to make the code work. The button will work as a traffic button for pedestrians to change the light whenever they like. Connect the button to digital pin 12.

Step 5: LED's

The LED's have two different legs, one positive and one negative. The longer leg is the positive and the short leg is negative. Connect the long leg of each LED to digital pins eight, nine, and ten via a 220? resistor. Connect the short leg to Arduino ground.

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    Discussions

    None
    seamster

    10 months ago

    Thank you for sharing your first project! Welcome to Instructables : )
    Do you happen to have an image of that actual project you made, that you could use for the cover/thumbnail image (to replace that main image in intro)? That would be a small improvement that would help a lot. Just a tip! : )