Skip to content

Instantly share code, notes, and snippets.

@HectorTorres
Created July 22, 2020 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HectorTorres/1b399462414d2d17ecb563955cc4e6c4 to your computer and use it in GitHub Desktop.
Save HectorTorres/1b399462414d2d17ecb563955cc4e6c4 to your computer and use it in GitHub Desktop.
#define PinBuzzer 7
#define SoundTime 2000
#define PinSignal 8
void setup() {
pinMode(PinBuzzer, OUTPUT);
pinMode(PinSignal, INPUT);
}
void loop() {
if(digitalRead(PinSignal)==HIGH){
digitalWrite(PinBuzzer,HIGH);
delay(SoundTime);
}
else{
digitalWrite(PinBuzzer,LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment