azaz84ok55
Published © GPL3+

Traffic light with counter

An led traffic light with with extra counter liquid crystal LCD.

BeginnerShowcase (no instructions)2,585
Traffic light with counter

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
between 220 and 1k works
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
5 mm LED: Green
5 mm LED: Green
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

schematic

schematic

Code

code

C/C++
#include <LiquidCrystal.h>
const int green_pin=8;
const int yellow_pin=9;
const int red_pin=10;
const int green_delay=12000;
const int yellow_delay=3000;
const int red_delay=12000;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void green()
{
  for(int time1=12;time1>0;time1--)
  {
    digitalWrite(green_pin, HIGH);
    digitalWrite(yellow_pin, LOW);
    digitalWrite(red_pin, LOW);  
    lcd.print(time1);
    delay(1000);
    lcd.clear();
  }
}
void yellow()
{  
  for(int time2=3;time2>0;time2--)
  {
    digitalWrite(green_pin, LOW);
    digitalWrite(yellow_pin, HIGH);
    digitalWrite(red_pin, LOW);  
    lcd.print(time2);
    delay(1000);
    lcd.clear();
  }
}
void red()
{
  for(int time3=12;time3>0;time3--)
  {
    digitalWrite(green_pin, LOW);
    digitalWrite(yellow_pin, LOW);
    digitalWrite(red_pin, HIGH);  
    lcd.print(time3);
    delay(1000);
    lcd.clear();
   }
}
void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  pinMode(green_pin, OUTPUT);
  pinMode(yellow_pin, OUTPUT);
  pinMode(red_pin, OUTPUT);
}
void loop()
{
  green();
  yellow();
  red(); 
}

Credits

azaz84ok55
2 projects • 1 follower

Comments