#define RED 1
#define YELLOW 5
#define GREEN 9
void setup() {
pinMode(RED, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(GREEN, OUTPUT);
digitalWrite(RED, LOW);
digitalWrite(YELLOW, LOW);
digitalWrite(GREEN, LOW);
Serial1.begin(9600);
Serial1.println("Enter the match percentage with image of empty road");
}
void loop() {
while (Serial1.available() == 0) {
Serial1.setTimeout(3000);
int match = 70;
Serial1.println("Received match percentage: ");
Serial1.print(match);
digitalWrite(GREEN, HIGH);
if (match < 20)
delay(6000);
else if (match >= 20 && match < 50)
delay(4000);
else if (match >= 50 && match < 75)
delay(3000);
else if (match >= 75 && match <= 100)
delay(2000);
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, HIGH);
delay(1000);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, HIGH);
delay(2000);
digitalWrite(RED, LOW);
}
}