pandajunior456
Published © Apache-2.0

LED traffic control

It is a basic project for beginners who are interested in arduino

BeginnerProtip101
LED traffic control

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
Male - Male jumper wires hence we do it in the breadboard
×4
5 mm LED: Red
5 mm LED: Red
traffic light has red yellow and green you will need those
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
5 mm LED: Green
5 mm LED: Green
×1
Arduino UNO
Arduino UNO
You can't miss the arduino uno
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
direct connections can be made but i think it may be messy so i rather will use the breadboard
×1
Resistor 1k ohm
Resistor 1k ohm
Resistor is also very important
×3

Story

Read more

Code

Untitled file

Arduino
// variables
int GREEN = 2;
int YELLOW = 3;
int RED = 4;
int DELAY_GREEN = 5000;
int DELAY_YELLOW = 2000;
int DELAY_RED = 5000;


// basic functions
void setup()
{
  pinMode(GREEN, OUTPUT);
  pinMode(YELLOW, OUTPUT);
  pinMode(RED, OUTPUT);
}

void loop()
{
  green_light();
  delay(DELAY_GREEN);
  yellow_light();
  delay(DELAY_YELLOW);
  red_light();
  delay(DELAY_RED);
}

void green_light()
{
  digitalWrite(GREEN, HIGH);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, LOW);
}

void yellow_light()
{
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, HIGH);
  digitalWrite(RED, LOW);
}

void red_light()
{
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, HIGH);
}

Credits

pandajunior456
0 projects • 0 followers

Comments