Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
armath_arinj
Published © GPL3+

Traffic lights

Traffic lights using Arduino and leds.

BeginnerProtip140
Traffic lights

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
LED (generic)
LED (generic)
×5
Transistor 220 v
×1
Male/Male Jumper Wires
×6

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

stunning_jarv_wZQ2DXWqT5.png

Code

Traffic lights-Arduino

Arduino
#AUTHOR IS ARMATH ENGENEERING LABORATORIE OF ARINJ
int GREEN = 2;
int YELLOW = 3;
int RED = 4;
int green = 5;
int red = 6;

void setup()
{
  pinMode(GREEN, OUTPUT);
  pinMode(YELLOW, OUTPUT);
  pinMode(RED, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(red, OUTPUT);
  }

void loop()
{
  green_light();
  delay(5000);
  yellow_light();
  delay(2000);
  red_light();
  delay(5000);
  green_light();
  delay(5000);
  red_light();
  delay(5000);
  }

void green_light()
{
  digitalWrite(GREEN, HIGH);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, LOW);
  digitalWrite(green, LOW);
  digitalWrite(red, HIGH);
  }
void yellow_light()
{
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, HIGH);
  digitalWrite(RED, LOW);
  }
void red_light()
{
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, HIGH);
  digitalWrite(green, HIGH);
  digitalWrite(red, LOW);
  }

Credits

armath_arinj

armath_arinj

0 projects • 0 followers

Comments