Skip to content

AhmedHusseinElsayed19/Alarm-Clock-using-FSM

Repository files navigation

The initial task involves creating a 24-hour clock with a remarkable 1-millisecond resolution. To achieve this, we can expand the capabilities of the existing scheduler by leveraging its 1-millisecond timer callback. This expansion entails introducing a private time-keeping variable, denoted as "systemTime_t," to accurately store and update the current time at 1-millisecond intervals. When the microcontroller powers up, the clock lacks an initial time reference. Consequently, users must manually set the time via button interactions.

During the uninitialized state, the display showcases a clock in HH:MM format, with an additional line guiding users to set the time. The hour setting is accomplished by repeatedly pressing the Rotary Button, and once completed, the Joystick Button is pressed to move on to configuring the minutes using the Rotary Button. A second press of the Joystick Button finalizes the time setting and initiates clock operation. During normal operation, the time is presented in HH:MM:SS format.

In normal operation mode, users can employ the Rotary Button to toggle the alarm state, and the display is indicative of this status. If the Joystick Button is pressed, the alarm time can be set, and the display line shifts to showing the alarm time in HH:MM format. When the alarm is enabled and the system time aligns with the set alarm time, the red LED blinks at a 4 Hz frequency. The alarm ceases upon any button press or after a 5-second period elapses.

Crucially, the alarm should only trigger when the clock is in its regular operational mode, meaning it must not be activated while configuring the alarm time. Furthermore, the LEDs serve various functionalities: the green LED blinks in sync with the seconds counter, the yellow LED indicates alarm activation, and the red LED flashes at 4 Hz during alarm activation and remains off otherwise.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages