// Import the necessary libraries
#include <LiquidCrystal.h>
// Define the pins for the LCD
const int rs = 12, en = 13, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
// Create a new LCD object
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Define the pins for the LEDs
int signal1[] = {23, 25, 27};
int signal2[] = {46, 48, 50};
int signal3[] = {13, 12, 11};
int signal4[] = {10, 9, 8};
// Define the delay times
int redDelay = 5000;
int yellowDelay = 2000;
void setup() {
// Initialize the serial port
Serial.begin(9600);
// Initialize the LCD
lcd.begin(16, 2);
// Set the pins for the LEDs as output
for (int i = 0; i < 3; i++) {
pinMode(signal1[i], OUTPUT);
pinMode(signal2[i], OUTPUT);
pinMode(signal3[i], OUTPUT);
pinMode(signal4[i], OUTPUT);
}
}
void print(){
lcd.print("shakthi");
}
void loop() {
// Make the green LED at signal 1 turn on
digitalWrite(signal1[2], HIGH);
// Write the current lane to the LCD
lcd.clear();
lcd.print("Lane 1");
// Wait for the red delay to elapse
delay(redDelay);
// Make the yellow LED at signal 1 turn on
digitalWrite(signal1[1], HIGH);
// Wait for the yellow delay to elapse
delay(yellowDelay);
// Make the green LED at signal 1 turn off
digitalWrite(signal1[2], LOW);
// Make the red LED at signal 2 turn on
digitalWrite(signal2[2], HIGH);
// Write the current lane to the LCD
lcd.clear();
lcd.print("Lane 2");
// Wait for the red delay to elapse
delay(redDelay);
// Make the yellow LED at signal 2 turn on
digitalWrite(signal2[1], HIGH);
// Wait for the yellow delay to elapse
delay(yellowDelay);
// Make the green LED at signal 2 turn off
digitalWrite(signal2[2], LOW);
// Make the red LED at signal 3 turn on
digitalWrite(signal3[2], HIGH);
// Write the current lane to the LCD
lcd.clear();
lcd.print("Lane 3");
// Wait for the red delay to elapse
delay(redDelay);
// Make the yellow LED at signal 3 turn on
digitalWrite(signal3[1], HIGH);
// Wait for the yellow delay to elapse
delay(yellowDelay);
// Make the green LED at signal 3 turn off
digitalWrite(signal3[2], LOW);
// Make the red LED at signal 4 turn on
digitalWrite(signal4[2], HIGH);
// Write the current lane to the LCD
lcd.clear();
lcd.print("Lane 4");
// Wait for the red delay to elapse
delay(redDelay);
// Make the yellow LED at signal 4 turn on
digitalWrite(signal4[1], HIGH);
// Wait for the yellow delay to elapse
delay(yellowDelay);
// Make the green LED at signal 4 turn off
digitalWrite(signal4[2], LOW);
}