Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Goods shed building and security lights turned on and off on schedule.
- 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
- You are free to use this sketch and amend it for your own personal use as long these credits remain intact.
- Using it in any manner or form for commercial purposes is prohibed.*/
- #define buildingSwitch A4
- #define securitySwitch A5
- //************************************
- #define office2 2
- #define shed3 3
- #define office 4
- #define shed1 5
- #define shed2 6
- //*****************************
- #define security1 7
- #define security2 8
- #define security3 9
- #define security4 10
- #define security5 11
- #define security6 12
- #define security7 A3
- int valbuilding = 0;
- int valsecurity = 0;
- //********************************************
- void setup() {
- pinMode(office2, OUTPUT);
- pinMode(shed3, OUTPUT);
- pinMode(office, OUTPUT);
- pinMode(shed1, OUTPUT);
- pinMode(shed2, OUTPUT);
- pinMode(security1, OUTPUT);
- pinMode(security2, OUTPUT);
- pinMode(security3, OUTPUT);
- pinMode(security4, OUTPUT);
- pinMode(security5, OUTPUT);
- pinMode(security6, OUTPUT);
- pinMode(security7, OUTPUT);
- pinMode(buildingSwitch, INPUT);
- pinMode(securitySwitch, INPUT);
- }
- //Routine
- void loop() {
- buildingLights();
- securityLights();
- }
- //Cycles
- //*********************************************************
- //Building Lights
- void buildingLights() {
- valbuilding = digitalRead(buildingSwitch);
- if (valbuilding == HIGH) {
- digitalWrite(office, HIGH);
- delay(2500);
- digitalWrite(office2, HIGH);
- delay(5000);
- digitalWrite(shed1, HIGH);
- delay(2000);
- digitalWrite(shed2, HIGH);
- delay (2000);
- digitalWrite(shed3, HIGH);
- }
- if (valbuilding == LOW) {
- digitalWrite(shed1, LOW);
- delay(2000);
- digitalWrite(shed2, LOW);
- delay(2500);
- digitalWrite(shed3, LOW);
- delay(5000);
- digitalWrite(office, LOW);
- }
- }
- //******************************************
- //*****************************************
- void securityLights() {
- valsecurity = digitalRead(securitySwitch);
- if (valsecurity == HIGH) {
- digitalWrite(security1, HIGH);
- delay(1000);
- digitalWrite(security2, HIGH);
- delay(1000);
- digitalWrite(security3, HIGH);
- delay(1000);
- digitalWrite(security4, HIGH);
- delay(1000);
- digitalWrite(security5, HIGH);
- delay(1000);
- digitalWrite(security6, HIGH);
- delay(1000);
- digitalWrite(security7, HIGH);
- delay(1000);
- }
- if (valsecurity == LOW) {
- digitalWrite(security1, LOW);
- delay(1000);
- digitalWrite(security2, LOW);
- delay(2000);
- digitalWrite(security3, LOW);
- delay(2000);
- digitalWrite(security4, LOW);
- delay(2000);
- digitalWrite(security5, LOW);
- delay(2000);
- digitalWrite(security6, LOW);
- delay(2000);
- digitalWrite(security7, LOW);
- delay(2000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement