Advertisement
kartonman

Goods Shed Building Lights

Feb 23rd, 2022
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. /*Goods shed building and security lights turned on and off on schedule.
  2. This sketch created and copywrite by Gary C. Granai https://www.facebook.com/gary.granai and is included in the Arduino For Model Railing Library at https://steamtraininfo.com/arduino-projects
  3.  
  4. You are free to use this sketch and amend it for your own personal use as long these credits remain intact.
  5. Using it in any manner or form for commercial purposes is prohibed.*/
  6.  
  7.  
  8. #define buildingSwitch A4
  9. #define securitySwitch A5
  10. //************************************
  11. #define office2 2
  12. #define shed3 3
  13. #define office 4
  14. #define shed1 5
  15. #define shed2 6
  16. //*****************************
  17. #define security1 7
  18. #define security2 8
  19. #define security3 9
  20. #define security4 10
  21. #define security5 11
  22. #define security6 12
  23. #define security7 A3
  24. int valbuilding = 0;
  25. int valsecurity = 0;
  26.  
  27. //********************************************
  28. void setup() {
  29. pinMode(office2, OUTPUT);
  30. pinMode(shed3, OUTPUT);
  31. pinMode(office, OUTPUT);
  32. pinMode(shed1, OUTPUT);
  33. pinMode(shed2, OUTPUT);
  34. pinMode(security1, OUTPUT);
  35. pinMode(security2, OUTPUT);
  36. pinMode(security3, OUTPUT);
  37. pinMode(security4, OUTPUT);
  38. pinMode(security5, OUTPUT);
  39. pinMode(security6, OUTPUT);
  40. pinMode(security7, OUTPUT);
  41.  
  42. pinMode(buildingSwitch, INPUT);
  43. pinMode(securitySwitch, INPUT);
  44. }
  45.  
  46. //Routine
  47. void loop() {
  48. buildingLights();
  49. securityLights();
  50. }
  51. //Cycles
  52. //*********************************************************
  53. //Building Lights
  54. void buildingLights() {
  55. valbuilding = digitalRead(buildingSwitch);
  56. if (valbuilding == HIGH) {
  57. digitalWrite(office, HIGH);
  58. delay(2500);
  59. digitalWrite(office2, HIGH);
  60. delay(5000);
  61. digitalWrite(shed1, HIGH);
  62. delay(2000);
  63. digitalWrite(shed2, HIGH);
  64. delay (2000);
  65. digitalWrite(shed3, HIGH);
  66. }
  67.  
  68. if (valbuilding == LOW) {
  69.  
  70. digitalWrite(shed1, LOW);
  71. delay(2000);
  72. digitalWrite(shed2, LOW);
  73. delay(2500);
  74. digitalWrite(shed3, LOW);
  75. delay(5000);
  76. digitalWrite(office, LOW);
  77. }
  78. }
  79. //******************************************
  80. //*****************************************
  81. void securityLights() {
  82. valsecurity = digitalRead(securitySwitch);
  83. if (valsecurity == HIGH) {
  84. digitalWrite(security1, HIGH);
  85. delay(1000);
  86. digitalWrite(security2, HIGH);
  87. delay(1000);
  88. digitalWrite(security3, HIGH);
  89. delay(1000);
  90. digitalWrite(security4, HIGH);
  91. delay(1000);
  92. digitalWrite(security5, HIGH);
  93. delay(1000);
  94. digitalWrite(security6, HIGH);
  95. delay(1000);
  96. digitalWrite(security7, HIGH);
  97. delay(1000);
  98.  
  99. }
  100.  
  101. if (valsecurity == LOW) {
  102.  
  103. digitalWrite(security1, LOW);
  104. delay(1000);
  105. digitalWrite(security2, LOW);
  106. delay(2000);
  107. digitalWrite(security3, LOW);
  108. delay(2000);
  109. digitalWrite(security4, LOW);
  110. delay(2000);
  111. digitalWrite(security5, LOW);
  112. delay(2000);
  113. digitalWrite(security6, LOW);
  114. delay(2000);
  115. digitalWrite(security7, LOW);
  116. delay(2000);
  117.  
  118. }
  119. }
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement