2022-03-29 07:59:41 +00:00
|
|
|
#define LOW_POWER_SLEEP // dependency: Adafruit SleepyDog
|
2022-03-29 05:22:25 +00:00
|
|
|
|
2022-03-29 07:59:41 +00:00
|
|
|
#define SLOW_START_DELAY 5000 // ms
|
2022-03-29 05:22:25 +00:00
|
|
|
#define PIN_SPEAKER 12
|
|
|
|
|
|
|
|
#define RELAYS 8
|
|
|
|
int relayPins[] = {
|
|
|
|
2, 3, 4, 5, 6, 7, 8, 9
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef LOW_POWER_SLEEP
|
|
|
|
#include <Adafruit_SleepyDog.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void beep(int freq, int ms) {
|
|
|
|
tone(PIN_SPEAKER, freq, ms);
|
|
|
|
delay(ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
|
|
digitalWrite(LED_BUILTIN, HIGH);
|
|
|
|
for (int i = 0; i < RELAYS; i++) {
|
|
|
|
pinMode(relayPins[i], OUTPUT);
|
|
|
|
digitalWrite(relayPins[i], LOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
Serial.begin(115200);
|
|
|
|
while (!Serial)
|
|
|
|
delay(10);
|
|
|
|
|
|
|
|
Serial.println();
|
|
|
|
Serial.println(" [ Slow-start Power Socket ] ");
|
|
|
|
|
|
|
|
beep(440, 200);
|
|
|
|
delay(1000);
|
|
|
|
|
|
|
|
for (int i = 0; i < RELAYS; i++) {
|
|
|
|
Serial.println("...");
|
2022-03-29 07:59:41 +00:00
|
|
|
delay(SLOW_START_DELAY/2);
|
2022-03-29 05:22:25 +00:00
|
|
|
beep(100, 10);
|
2022-03-29 07:59:41 +00:00
|
|
|
delay(SLOW_START_DELAY/2);
|
2022-03-29 05:22:25 +00:00
|
|
|
|
|
|
|
Serial.print("Starting ");
|
|
|
|
Serial.print(i+1);
|
|
|
|
Serial.print(" ... ");
|
|
|
|
|
|
|
|
beep(200, 50);
|
|
|
|
digitalWrite(relayPins[i], HIGH);
|
|
|
|
|
|
|
|
Serial.println("Done.");
|
|
|
|
beep(460, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
Serial.println();
|
|
|
|
Serial.println("Finished!");
|
|
|
|
delay(1000);
|
|
|
|
beep(210, 100);
|
|
|
|
beep(420, 100);
|
2022-03-29 07:59:41 +00:00
|
|
|
beep(560, 500);
|
2022-03-29 05:22:25 +00:00
|
|
|
digitalWrite(LED_BUILTIN, LOW);
|
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
// nothing to do!
|
|
|
|
#ifdef LOW_POWER_SLEEP
|
|
|
|
Watchdog.sleep();
|
|
|
|
#else
|
|
|
|
delay(1000);
|
|
|
|
#endif
|
|
|
|
}
|