#define FET 8 #define testFET 0 #define SWLIGHT 10 #define SWREED 11 #define LED 13 //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); pinMode(LED, OUTPUT); } void loop() { //test the fet /* 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(1000); // 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); //Use onboard LED to monitor whether magnet reed is synced or not if(SWREEDvar == 1){ digitalWrite(LED, 1); //magnet not connected to reed } else{ digitalWrite(LED, 0); //magnet connected } //trigger FET and Actuator if(SWLIGHTvar == 0){ if(SWREEDvar == 1){ digitalWrite(FET, 1); // turn on (HIGH is the voltage level) delay(80); // wait digitalWrite(FET, 0); // turn off by making the voltage LOW delay(15000); // wait for 15 seconds } goto breakout; } //if light switch is 5v, do nothing, wait 3 seconds delay(3000); breakout: delay(100); }