Smart Home Automation Forum

Full Version: [Arduino source code for KC868-ASR]-04 BEEP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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);
}