Skip to content

Instantly share code, notes, and snippets.

@shockwaves
Created January 4, 2019 20:03
Show Gist options
  • Save shockwaves/f507e7422df1b5e0aa7e40ba81b447ae to your computer and use it in GitHub Desktop.
Save shockwaves/f507e7422df1b5e0aa7e40ba81b447ae to your computer and use it in GitHub Desktop.
arduino-door-alarm
#define pinDoor 2
#define pinAlarm 3
int doorStatus;
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(pinAlarm, OUTPUT);
pinMode(pinDoor, INPUT_PULLUP);
}
void loop() {
doorStatus = digitalRead(pinDoor);
digitalWrite(LED_BUILTIN, doorStatus);
digitalWrite(pinAlarm, !doorStatus);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment