#include <LiquidCrystal_I2C.h>
#include <Wire.h>
// I2C LCD display addresses
const int lcdAddress1 = 0x27; // Replace with the actual I2C address of LCD 1
const int lcdAddress2 = 0x28; // Replace with the actual I2C address of LCD 2
const int lcdAddress3 = 0x29; // Replace with the actual I2C address of LCD 3
// I2C LCD displays
LiquidCrystal_I2C lcd1(lcdAddress1, 16, 2);
LiquidCrystal_I2C lcd2(lcdAddress2, 16, 2);
LiquidCrystal_I2C lcd3(lcdAddress3, 16, 2);
int signal1[] = {26, 25, 33};
int signal2[] = {19, 18, 5};
int signal3[] = {32, 35, 34};
int signal4[] = {17, 16, 15};
int redDelay = 5000;
int yellowDelay = 2000;
void setup() {
// Declaring all the LED's 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 loop() {
// Making Green LED at signal 1 and red LED's at other signal HIGH
digitalWrite(signal1[2], HIGH);
digitalWrite(signal1[0], LOW);
digitalWrite(signal2[0], HIGH);
digitalWrite(signal3[0], HIGH);
digitalWrite(signal4[0], HIGH);
delay(redDelay);
// Making Green LED at signal 1 LOW and making yellow LED at signal 1 HIGH for 2 seconds
digitalWrite(signal1[1], HIGH);
digitalWrite(signal1[2], LOW);
delay(yellowDelay);
digitalWrite(signal1[1], LOW);
// Making Green LED at signal 2 and red LED's at other signal HIGH
digitalWrite(signal1[0], HIGH);
digitalWrite(signal2[2], HIGH);
digitalWrite(signal2[0], LOW);
digitalWrite(signal3[0], HIGH);
digitalWrite(signal4[0], HIGH);
delay(redDelay);
// Making Green LED at signal 2 LOW and making yellow LED at signal 2 HIGH for 2 seconds
digitalWrite(signal2[1], HIGH);
digitalWrite(signal2[2], LOW);
delay(yellowDelay);
digitalWrite(signal2[1], LOW);
// Making Green LED at signal 3 and red LED's at other signal HIGH
digitalWrite(signal1[0], HIGH);
digitalWrite(signal2[0], HIGH);
digitalWrite(signal3[2], HIGH);
digitalWrite(signal3[0], LOW);
digitalWrite(signal4[0], HIGH);
delay(redDelay);
// Making Green LED at signal 3 LOW and making yellow LED at signal 3 HIGH for 2 seconds
digitalWrite(signal3[1], HIGH);
digitalWrite(signal3[2], LOW);
delay(yellowDelay);
digitalWrite(signal3[1], LOW);
// Making Green LED at signal 4 and red LED's at other signal HIGH
digitalWrite(signal1[0], HIGH);
digitalWrite(signal2[0], HIGH);
digitalWrite(signal3[0], HIGH);
digitalWrite(signal4[2], HIGH);
digitalWrite(signal4[0], LOW);
delay(redDelay);
// Making Green LED at signal 4 LOW and making yellow LED at signal 4 HIGH for 2 seconds
digitalWrite(signal4[1], HIGH);
digitalWrite(signal4[2], LOW);
delay(yellowDelay);
digitalWrite(signal4[1], LOW);
}