You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB

4 years ago
  1. #define FET 8
  2. #define testFET 0
  3. #define SWLIGHT 10
  4. #define SWREED 11
  5. //Switches on Pins 10, and 11
  6. //Switch 10, is light switch. Ground when switch is up (ON).
  7. //Switch 11, is magnet reed switch, Ground when door is closed.
  8. uint8_t SWLIGHTvar = 0;
  9. uint8_t SWREEDvar = 0;
  10. void setup() {
  11. pinMode(FET, OUTPUT);
  12. pinMode(SWLIGHT, INPUT);
  13. pinMode(SWREED, INPUT);
  14. }
  15. void loop() {
  16. /*if(testFET){
  17. while(1){
  18. digitalWrite(FET, HIGH); // turn the LED on (HIGH is the voltage level)
  19. delay(100); // wait for a second
  20. digitalWrite(FET, LOW); // turn the LED off by making the voltage LOW
  21. delay(3000); // wait for a second
  22. }
  23. }*/
  24. /* OUTLINE */
  25. //Read light switch, read magnet switch
  26. //if light switch is 5v, do nothing, wait 3 seconds
  27. //if light switch is gnd, continue
  28. //if reed switch is gnd, do nothing, wait 100 ms
  29. //if reed switch is high, continue
  30. //ring bell, sleep for 10 seconds
  31. SWLIGHTvar = digitalRead(SWLIGHT);
  32. SWREEDvar = digitalRead(SWREED);
  33. if(SWLIGHTvar == 0){
  34. if(SWREEDvar == 1){
  35. digitalWrite(FET, HIGH); // turn the LED on (HIGH is the voltage level)
  36. delay(100); // wait for a second
  37. digitalWrite(FET, LOW); // turn the LED off by making the voltage LOW
  38. delay(10000); // wait for a second
  39. }
  40. goto breakout;
  41. }
  42. //if light switch is 5v, do nothing, wait 3 seconds
  43. delay(3000);
  44. breakout:
  45. delay(100);
  46. }