const int redLED_L = 4; const int redLED_R = 14; const int greenLED = 9; const int button_L = 1; const int button_R = 16; void setup() { // put your setup code here, to run once: pinMode(redLED_L,OUTPUT); pinMode(redLED_R,OUTPUT); pinMode(greenLED,OUTPUT); pinMode(button_L,OUTPUT); pinMode(button_R,OUTPUT); Serial.begin(9600); attachInterrupt(button_L,LPress,RISING); attachInterrupt(button_R,RPress,RISING); } void loop() { // put your main code here, to run repeatedly: if (Serial.available()>0){ char Data=Serial.read(); if (Data=='n'){ // digitalWrite(outpin1,HIGH); digitalWrite(redLED_L,HIGH); digitalWrite(redLED_R,HIGH); delay(1000); digitalWrite(redLED_L,LOW); digitalWrite(redLED_R,LOW); } else if (Data=='y'){ // digitalWrite(outpin2,HIGH); for (int i = 0; i < 5; i++){ digitalWrite(greenLED,HIGH); delay(500); digitalWrite(greenLED,LOW); delay(250); } } else if (Data=='p'){ digitalWrite(greenLED,HIGH); delay(100); digitalWrite(greenLED,LOW); delay(100); } delay(1000); // digitalWrite(outpin1,LOW); // digitalWrite(outpin2,LOW); } } void LPress() { Serial.print('a'); delay(1000); } void RPress() { Serial.print('b'); delay(1000); }