#define LED 2
#define S1 3
#define S2 4
#define S3 5
#define buzz 6
bool toggleLED = false;
int PSS1, PSS2; //(PSSI = PRESS AND REALEASE)
int counter;
void setup() {
pinMode(LED, OUTPUT);
pinMode(S1, INPUT_PULLUP);
pinMode(S2, INPUT_PULLUP);
pinMode(S3, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
/////////////////////////////////////////////////
// if(PSS1 == 0){
// if(digitalRead(S1) == 0){
// PSS1=1;
// }
// }
// if(PSS1 == 1){
// if(digitalRead(S2) == 0){
// PSS1=2;
// }
// }
// if(PSS1 == 2){
// if(digitalRead(S3) == 0){
// SW1 = !SW1;
// digitalWrite(LED, SW1);
// PSS1=0;
// }
// }
// }
/////////////////////////////////////////////////
// if(digitalRead(S1) == 0){
// while(digitalRead(S1) == 0){}
// toggleLED = !toggleLED;
// digitalWrite(LED, toggleLED);
// }
// if(digitalRead(S2) == 0){
// toggleLED = !toggleLED;
// digitalWrite(LED, toggleLED);
// while(digitalRead(S2) == 0){}
// }
////////////////////////////////////////////////
// if (PSS1 == 0 && digitalRead(S1) == 0){
// PSS1 = 1;
// }
// if (PSS1 == 1 && digitalRead(S1) == 1){
// toggleLED = !toggleLED;
// digitalWrite(LED, toggleLED);
// PSS1 = 0;
// }
/////////////////////////////////////////////////
Serial.println(counter);
// if (PSS1 == 0 && digitalRead(S1) == 0 && counter < 10){
// counter++;
// // if (counter > 10){
// // counter = 10;
// // }
// tone(buzz, 500);
// delay(10);
// noTone(buzz);
// PSS1 = 1;
// }
// if (PSS1 == 1 && digitalRead(S1) == 1){
// PSS1 = 0;
// }
// if (PSS2 == 0 && digitalRead(S2) == 0 && counter > 0){
// counter--;
// // if (counter < 0){
// // counter = 0;
// // }
// tone(buzz, 500);
// delay(10);
// noTone(buzz);
// PSS2 = 1;
// }
// if (PSS2 == 1 && digitalRead(S2) == 1){
// PSS2 = 0;
// }
if (digitalRead(S1) == 0 && counter < 10){
while(digitalRead(S1) == 0) {}
counter++;
tone(buzz, 500);
delay(10);
noTone(buzz);
}
}