Browse Source

cod

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

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

@ -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);
}

Loading…
Cancel
Save