From b0a38bbbb2d2e86edfcf5fd49a1dfbca242fab58 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 25 Feb 2020 22:21:55 -0500 Subject: [PATCH] cod --- Door_Chime/code/Door_Chime/Door_Chime.ino | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Door_Chime/code/Door_Chime/Door_Chime.ino diff --git a/Door_Chime/code/Door_Chime/Door_Chime.ino b/Door_Chime/code/Door_Chime/Door_Chime.ino new file mode 100644 index 0000000..2385502 --- /dev/null +++ b/Door_Chime/code/Door_Chime/Door_Chime.ino @@ -0,0 +1,60 @@ +#define FET 8 +#define testFET 0 + +#define SWLIGHT 10 +#define SWREED 11 + +//Switches on Pins 10, and 11 +//Switch 10, is light switch. Ground when switch is up (ON). +//Switch 11, is magnet reed switch, Ground when door is closed. + +uint8_t SWLIGHTvar = 0; +uint8_t SWREEDvar = 0; + +void setup() { + pinMode(FET, OUTPUT); + pinMode(SWLIGHT, INPUT); + pinMode(SWREED, INPUT); +} + +void loop() { + /*if(testFET){ + while(1){ + digitalWrite(FET, HIGH); // turn the LED on (HIGH is the voltage level) + delay(100); // wait for a second + digitalWrite(FET, LOW); // turn the LED off by making the voltage LOW + delay(3000); // wait for a second + } + }*/ + +/* OUTLINE */ + //Read light switch, read magnet switch + //if light switch is 5v, do nothing, wait 3 seconds + //if light switch is gnd, continue + //if reed switch is gnd, do nothing, wait 100 ms + //if reed switch is high, continue + //ring bell, sleep for 10 seconds + + + + SWLIGHTvar = digitalRead(SWLIGHT); + SWREEDvar = digitalRead(SWREED); + + if(SWLIGHTvar == 0){ + if(SWREEDvar == 1){ + digitalWrite(FET, HIGH); // turn the LED on (HIGH is the voltage level) + delay(100); // wait for a second + digitalWrite(FET, LOW); // turn the LED off by making the voltage LOW + delay(10000); // wait for a second + } + goto breakout; + } + + //if light switch is 5v, do nothing, wait 3 seconds + delay(3000); + breakout: + delay(100); + + + +}