Hello everyone. I'm Lucas, from lafabriquediy.com
I have already asked the person who wrote this code for assistance but he says he is busy. And I'm not sure if he will be helping me. So, I decided to ask it here too. The code length is over the allowed 9000 character limit. So, I will be pasting it in 3-4 pieces. And I will be attaching the arduino IDE ino file.
It is about a 24-hour, binary coded decimal clock with the alarm function. The clock is driven by Arduino Uno. It uses the DS3231 RTC module for timekeeping.
INTENDED CLOCK OPERATION:
The functions of the clock are controlled by 4 buttons:
- A push-button for setting Hours;
- A push-button for setting Minutes;
- A push-button for Alarm function;
- A normal button for Lights On/Off switch.
Clock behaviour:
-
Long pressing Alarm Button activates or deactivates the alarm. When alarm is activated, rows of LEDs light up in sequence from bottom to top and this is accompanied with rising piezo tones to indicate that alarm has just been activated/switched ON. The alarm deactivation effect is the opposite of this.
-
Long pressing hour and minute buttons together, switches the clock to Setting Mode. Within the setting mode, there are two modes:
- Alarm Time setting mode;
- Clock Time setting mode.
In Setting Mode, as you are setting time, the hours or minutes will blink depending on which one you have got selected.
You can move between Alarm Time Setting Mode and Clock Time Setting Mode by short pressing the Alarm Button. When you have finished setting alarm time and/or clock time, you long press hour and minute buttons again to store changes and exit to normal display mode.
Alarm sound: half-second beep followed by half-second pause, then 1 second beep followed by 1 second pause.
When the alarm goes off, all LEDs flash during the beeps and time is shown during the pauses. So, it creates a nice blinking effect that accompanies the alarm sound.
When the alarm is playing, pressing any of the push-buttons activates the Snooze Mode which lasts for 5 minutes after which the alarm is triggered again. You can Snooze as many times as you like. If you don't take any action, the alarm will switch itself OFF in 10 minutes.
When the Lights On/Off button is in Off position, all lights are turned OFF and all user inputs are disabled in order to keep the user from pressing buttons blindly. If alarm goes off, the light switch is ignored and time is shown for as long as alarm is active.
When the clock is powered off, the RTC module keeps track of time using the backup battery. Alarm time is stored in EEPROM, so the clock retains alarm time over power cycles.
THE PROBLEM:
-- When alarm starts playing, (goes off) it has been designed so that the owner can snooze it with pressing of any button. When snoozed, alarm should play again after 5 minutes. This is OK. Or the owner can switch alarm off by LongPressing Alarm button. Also is working fine.
But if alarm is let to run the scheduled 10 minutes without owner input, the alarm switches itself off automatically -- then, something happens in the system and if you make a new alarm time, and the alarm time is reached, alarm starts playing and switches itself OFF immediately within 2 seconds. Doesn't even allow the alarm to run. It is as if, it remembers to switch itself off immediately. Something is broken there. It only happens if alarm is let to run 10 minutes and switch itself off. Cycling the power to the clock, fixes that.
arduinoware_sketch.ino (27.2 KB)