const int ButtonPin1 = 2;
const int delayLED = 2000;
const int LEDPin1 = 3;
const int ButtonPin2 = 4;
const int LEDPin2 = 5;
int RedButtonStatus = 0;
int RedlightStatus = 0;
int Redpushed = 0;
int YellowButtonStatus = 0;
int YellowlightStatus = 0;
int Yellowpushed = 0;
void setup() {
// Red
pinMode(ButtonPin1, INPUT_PULLUP);
pinMode(LEDPin1, OUTPUT);
Serial.begin(9600);
Serial.println("saisai pressed RED button");
// Yellow
pinMode(ButtonPin2, INPUT_PULLUP);
pinMode(LEDPin2, OUTPUT);
Serial.begin(9600);
Serial.println("saisai pressed YELLOW button");
}
void loop() {
//red;
RedButtonStatus = digitalRead(ButtonPin1);
Serial.println(RedButtonStatus);
if (RedButtonStatus == HIGH && RedlightStatus == LOW) {
Redpushed ^= 1;
delay(100);
}
RedlightStatus = RedButtonStatus;
if (Redpushed == HIGH) {
Serial.println("RED LIGHT ON");
digitalWrite(LEDPin1, HIGH);
}
else {
Serial.println("RED LIGHT OFF");
digitalWrite(LEDPin1, LOW);
}
//yellow;
YellowButtonStatus = digitalRead(ButtonPin2);
Serial.println(YellowButtonStatus);
if (YellowButtonStatus == HIGH && YellowlightStatus == LOW) {
Yellowpushed ^= 1;
delay(100);
}
YellowlightStatus = YellowButtonStatus;
if (Yellowpushed == HIGH) {
Serial.println("YELLOW LIGHT ON");
digitalWrite(LEDPin2, HIGH);
}
else {
Serial.println("YELLOW LIGHT OFF");
digitalWrite(LEDPin2, LOW);
}
}