Simple Traffic Light for Arduino

110

2

2

Posted

Introduction: Simple Traffic Light for Arduino

This Instructable will show you how to construct a Traffic Light for Arduino, cycling through LEDs for green, yellow, and res lights.

Step 1:

The Materials:

3 LEDs (red, yellow, and green lights)
Connecting wires
Arduino board
Breadboard
Resistors (220)

Step 2:

The Setup:
The long leg of each LED should be connected (using a 220 resistor) to the digital pins 8,9,10.
Each short leg goes to ground.
The wire connections should look like this diagram. C

Step 3:

Finally, once the setup has been completed, all that is left is the code, which looks like this:

int red=10;
int yellow=9;
int green=8;

void setup(){
pinMode (red, OUTPUT);
pinMode (yellow, OUTPUT);
pinMode (green, OUTPUT);
}

void loop (){
changeLights ();
delay (15000);
}
void changeLights (){
digitalWrite (green, LOW);
digitalWrite (yellow, HIGH);
delay (3000);
digitalWrite (yellow, LOW);
digitalWrite (red, HIGH);
delay (5000);
digitalWrite (yellow, HIGH);
delay (2000);
digitalWrite (yellow, LOW);
digitalWrite (red, LOW);
digitalWrite (green, HIGH);
delay (3000);
}

Step 4:

Once the code has been uploaded to the Arduino, your Traffic Light should be in working order, cycling through the three colors.

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Paper Contest 2018

    Paper Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

2 Comments

That's a good simple setup :)