03-02-2023, 06:39 AM
Code:
#define BEEP 18
#define S2 0
void setup() {
Serial.begin(115200);
pinMode(BEEP,OUTPUT);
pinMode(S2,INPUT);
digitalWrite(BEEP, HIGH);
delay(200);
digitalWrite(BEEP,LOW);
delay(200);
}
void loop() {
if(digitalRead(S2)==LOW){
delay(20);
if(digitalRead(S2)==LOW)
{
digitalWrite(BEEP, HIGH);
delay(100);
digitalWrite(BEEP, LOW);
delay(10);
}
}else digitalWrite(BEEP, LOW);
}