4
4
#include < DS3231.h>
5
5
#include < Wire.h>
6
6
#include < Eeprom24C32_64.h>
7
- #include < Eeprom24C04_16.h>
7
+ #include < Eeprom24C04_16.h>
8
+ #include < Watchdog.h>
8
9
9
10
10
11
#define BUZZER_PIN 10
@@ -48,6 +49,7 @@ Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS
48
49
// RTC
49
50
RTClib RTC;
50
51
52
+ Watchdog watchdog;
51
53
52
54
53
55
const bool morseKeys[10 ][5 ] = {
@@ -91,11 +93,13 @@ String userInputPrev = "";
91
93
92
94
93
95
void setup (){
96
+ watchdog.reset ();
94
97
Serial.begin (9600 );
95
98
Wire.begin ();
96
99
eeprom.initialize ();
97
100
pinMode (BUZZER_PIN, OUTPUT);
98
101
pinMode (LOCK_PIN, OUTPUT);
102
+ watchdog.enable (Watchdog::TIMEOUT_8S);
99
103
int size = sizeof (melodyMain) / sizeof (int );
100
104
playMaintenanceMelody (melodyMain, size);
101
105
}
@@ -109,6 +113,7 @@ void echo_morse_reversed_int(unsigned long value) {
109
113
// Serial.println(digit);
110
114
delay (MORSE_SOUND_TIME * MORSE_PAUSE);
111
115
for (int i =0 ; i < 5 ; i++ ) {
116
+ watchdog.reset ();
112
117
if (morseKeys[digit][i]) {
113
118
tone (BUZZER_PIN, MORSE_FREQ, MORSE_SOUND_TIME);
114
119
delay (MORSE_SOUND_TIME + MORSE_SOUND_TIME);
@@ -266,6 +271,7 @@ void buzz(int targetPin, long frequency, long length) {
266
271
void playMaintenanceMelody (int melody[], int size) {
267
272
int melodyPin = BUZZER_PIN;
268
273
for (int thisNote = 0 ; thisNote < size; thisNote++) {
274
+ watchdog.reset ();
269
275
// to calculate the note duration, take one second
270
276
// divided by the note type.
271
277
// e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
@@ -352,10 +358,12 @@ void makeMaintenance(String userInputPrev) {
352
358
353
359
354
360
void loop (){
361
+ watchdog.reset ();
355
362
digitalWrite (LOCK_PIN, LOW);
356
363
char customKey = customKeypad.getKey ();
357
364
if (customKey){
358
365
tone (BUZZER_PIN, FREQ_BUTTON_PRESS, SOUND_TIME_BUTTON_PRESS);
366
+ watchdog.reset ();
359
367
if (customKey == ' *' ) {
360
368
userInput = " " ;
361
369
userInputPrev = " " ;
0 commit comments