Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <EEPROM.h>
- bool IsRunning = true;
- const int START_DELAY = 5000; // delay before switching on start
- const int SwitchSS = 7; // pin7 on board
- const int SwitchLA = 8; // pin8 on board
- const int SwitchSM = 9; // pin9 on board
- const int RlySS = 10; // pin10 on board
- const int RlyLA = 11; // pin11 on board
- const int RlySM = 12; // pin12 on board
- void toggleSS()
- {
- int sVal = EEPROM.read(0);
- if (sVal == 1)
- {
- EEPROM.write(0, 0);
- }
- else
- {
- EEPROM.write(0, 1);
- }
- digitalWrite(RlySS, HIGH);
- delay(500);
- digitalWrite(RlySS, LOW);
- }
- void toggleLA()
- {
- int sVal = EEPROM.read(1);
- if (sVal == 1)
- {
- EEPROM.write(1, 0);
- }
- else
- {
- EEPROM.write(1, 1);
- }
- digitalWrite(RlyLA, HIGH);
- delay(500);
- digitalWrite(RlyLA, LOW);
- }
- void toggleSM()
- {
- int sVal = EEPROM.read(2);
- if (sVal == 1)
- {
- EEPROM.write(2, 0);
- }
- else
- {
- EEPROM.write(2, 1);
- }
- digitalWrite(RlySM, HIGH);
- delay(500);
- digitalWrite(RlySM, LOW);
- }
- bool SsState()
- {
- int sVal = EEPROM.read(0);
- if (sVal == 1)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- bool LaState()
- {
- int sVal = EEPROM.read(1);
- if (sVal == 1)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- bool SmState()
- {
- int sVal = EEPROM.read(2);
- if (sVal == 1)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- void setup() {
- pinMode(RlySS, OUTPUT);
- pinMode(RlyLA, OUTPUT);
- pinMode(RlySM, OUTPUT);
- pinMode(SwitchSS, INPUT_PULLUP);
- pinMode(SwitchLA, INPUT_PULLUP);
- pinMode(SwitchSM, INPUT_PULLUP);
- delay(START_DELAY);
- if (SsState() == true)
- {
- digitalWrite(RlySS, HIGH);
- }
- if (LaState() == true)
- {
- digitalWrite(RlyLA, HIGH);
- }
- if (SmState() == true)
- {
- digitalWrite(RlySM, HIGH);
- }
- delay(500);
- digitalWrite(RlySS, LOW);
- digitalWrite(RlyLA, LOW);
- digitalWrite(RlySM, LOW);
- delay(1000);
- IsRunning = false;
- }
- void loop() {
- if (IsRunning == false)
- {
- if (digitalRead(SwitchSS) == LOW)
- {
- toggleSS();
- }
- if (digitalRead(SwitchLA) == LOW)
- {
- toggleLA();
- }
- if (digitalRead(SwitchSM) == LOW)
- {
- toggleSM();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement