int redCounter = 0;
int greenCounter = 0;
int yellowCounter = 0;
void setup() {
Serial.begin(9600);
pinMode (0, INPUT_PULLUP);
pinMode (1, INPUT_PULLUP);
pinMode (2, INPUT_PULLUP);
pinMode (3, INPUT_PULLUP);
pinMode (5, OUTPUT);
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
}
void loop() {
if (digitalRead(1) == LOW) {
digitalWrite(5, HIGH);
redCounter++;
Serial.print("The RED LED was turned on ");
Serial.print(redCounter);
Serial.println(" times.");
delay(300);
}
if (digitalRead(2) == LOW) {
digitalWrite(6, HIGH);
greenCounter++;
Serial.print("The GREEN LED was turned on ");
Serial.print(greenCounter);
Serial.println(" times.");
delay(300);
}
if (digitalRead(3) == LOW) {
digitalWrite(7, HIGH);
yellowCounter++;
Serial.print("The YELLOW LED was turned on ");
Serial.print(yellowCounter);
Serial.println(" times.");
delay(300);
}
if (digitalRead(0) == LOW){
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
redCounter = 0;
greenCounter = 0;
yellowCounter = 0;
Serial.println("The reset button is pressed");
delay(300);
}
}