Browse Source

ok

master
Your Name 4 years ago
parent
commit
69651c63fa
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      Door_Chime/code/Door_Chime/Door_Chime.ino

+ 14
- 0
Door_Chime/code/Door_Chime/Door_Chime.ino View File

@ -4,6 +4,8 @@
#define SWLIGHT 10 #define SWLIGHT 10
#define SWREED 11 #define SWREED 11
#define LED 13
//Switches on Pins 10, and 11 //Switches on Pins 10, and 11
//Switch 10, is light switch. Ground when switch is up (ON). //Switch 10, is light switch. Ground when switch is up (ON).
//Switch 11, is magnet reed switch, Ground when door is closed. //Switch 11, is magnet reed switch, Ground when door is closed.
@ -15,6 +17,8 @@ void setup() {
pinMode(FET, OUTPUT); pinMode(FET, OUTPUT);
pinMode(SWLIGHT, INPUT); pinMode(SWLIGHT, INPUT);
pinMode(SWREED, INPUT); pinMode(SWREED, INPUT);
pinMode(LED, OUTPUT);
} }
void loop() { void loop() {
@ -40,6 +44,16 @@ void loop() {
SWLIGHTvar = digitalRead(SWLIGHT); SWLIGHTvar = digitalRead(SWLIGHT);
SWREEDvar = digitalRead(SWREED); 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(SWLIGHTvar == 0){
if(SWREEDvar == 1){ if(SWREEDvar == 1){
digitalWrite(FET, 1); // turn on (HIGH is the voltage level) digitalWrite(FET, 1); // turn on (HIGH is the voltage level)

Loading…
Cancel
Save