a code to implement a simple traffic signal and also display on LCD which color is ON? I have tried code given below for simple traffic signal and also display on LCD which color is ON, but it didn't work. Please me to make it work.


int red = 10;
int yellow = 9;
int green = 8;
#include &lt;LiquidCrystal.h&gt;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){
    pinMode(red, OUTPUT);
    pinMode(yellow, OUTPUT);
    pinMode(green, OUTPUT);
}

void loop(){
    changeLights();
    delay(1500);
}

void changeLights(){
    lcd.print("red");
    digitalWrite(yellow,LOW );
    digitalWrite(red, HIGH);
    digitalWrite(green,LOW );
    delay(3000);
    lcd.print("yellow");
    digitalWrite(yellow,HIGH );
    digitalWrite(red,LOW );
    digitalWrite(green,LOW );
    delay(3000);
    lcd.print("green");
    digitalWrite(yellow,LOW );
    digitalWrite(red,LOW );
    digitalWrite(green,HIGH );
    delay(3000);
    //if(
}
Write a sketch to test your LCD.

#include &lt;LiquidCrystal.h&gt;

LiquidCrystal lcd(12, 11, 5, 4, 4, 2);
void setup(){
    lcd.begin();
    lcd.print("Hello World!");
}
void loop() {
    lcd.setCursor(0, 1);
    lcd.print(millis() / 1000);
}


Make sure the R/W pin is connected to GND on your breadboard. You may need to connect the contrast pin to 5V. Ideally it should be connected to the wiper of a 10KOhm trimpot with either end connected to GND &amp; 5V (so you can vary the contrast).

Once that set-up works change your code

 void setup(){
     lcd.begin();
     lcd.print("Traffic signals");
     delay(500);
     pinMode(red, OUTPUT);
     pinMode(yellow, OUTPUT);
     pinMode(green, OUTPUT);
 }

 void loop(){
     changeLights();
     lcd.setCursor(0,0);
 }