|
|
@ -4,6 +4,8 @@ |
|
|
|
#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.
|
|
|
@ -15,6 +17,8 @@ void setup() { |
|
|
|
pinMode(FET, OUTPUT); |
|
|
|
pinMode(SWLIGHT, INPUT); |
|
|
|
pinMode(SWREED, INPUT); |
|
|
|
|
|
|
|
pinMode(LED, OUTPUT); |
|
|
|
} |
|
|
|
|
|
|
|
void loop() { |
|
|
@ -40,6 +44,16 @@ void loop() { |
|
|
|
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)
|
|
|
|