- 2069 Bhadra · 10 marks
Digital clock state diagram
Short answer
The clock has three states: Normal (display time/date), Set Time (adjust seconds), Set Date (adjust days). Mode button cycles Normal→Set Time→Set Date→Normal. Forward button increments by one unit; held >2s enters fast mode incrementing every 0.2s. Substates: Idle, Pressed, Fast with transitions on press, release, and after(2s).
A new digital clock, recently available in the market, simultaneously displays the time and date. The time and date displays can be adjusted by the buttons available within the unit. The clock has two buttons, "mode" and "forward". If you wish to change the time you should first press the mode button, after which the time may be changed by the forward-button. If the mode button is pressed again, you can change the date (by the forward-button). If the mode button is pressed once again, you will go back to normal state. When the forward-button is pressed, the display will go a single unit (seconds or days) ahead. If the button is held down for more than two seconds, the display will change rapidly (once in every 0.2 second) ahead so long as the button is pressed. Draw a state diagram for this clock control unit.
Assumptions: the clock has three modes: Normal (displays time and date, running), Set Time and Set Date. Events: mode and forward button presses, forward held for more than 2 s, and forward released. In Set Time one unit is one second; in Set Date one unit is one day.
State diagram
(*)
|
v
+----------------------+
| Normal |<--------------+
| do/ run clock, | |
| display time, date | |
+----------------------+ |
| |
mode |
v |
+----------------------+ |
| Set Time | |
| entry/ blink time | |
| forward: +1 second | |
+----------------------+ |
| |
mode |
v |
+----------------------+ mode |
| Set Date |---------------+
| entry/ blink date |
| forward: +1 day |
+----------------------+
The mode button cycles the states: Normal --mode--> Set Time --mode--> Set Date --mode--> Normal.
Substates for the forward button (inside Set Time and Set Date)
+----------------------------------------------------+
| (*) |
| | |
| v forward pressed / +1 unit |
| Idle ----------------------------> Pressed |
| ^ ^ | |
| | +------- forward released -------+ |
| | | after(2 s) |
| | v |
| +-------- forward released ------- Fast |
| do/ +1 unit every 0.2 s |
+----------------------------------------------------+
Transition table
| From | Event | To | Action |
|---|---|---|---|
| Normal | mode | Set Time | blink the time display |
| Set Time: Idle | forward pressed | Set Time: Pressed | time + 1 second |
| Pressed | after(2 s) while still pressed | Fast | none |
| Fast | every 0.2 s | Fast | time + 1 second |
| Pressed or Fast | forward released | Idle | stop incrementing |
| Set Time | mode | Set Date | blink the date display |
| Set Date | forward pressed / held | Set Date (same substates) | date + 1 day |
| Set Date | mode | Normal | resume the normal display |
The held-down behaviour is triggered by the time event after(2 s), and the repeated increment is timed with every(0.2 s).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Video rental shop class diagram · Object Oriented Analysis and Design, chapter 2
- Bottle recycling machine state diagram · Object Oriented Analysis and Design, chapter 2
- Student course department class diagram · Object Oriented Analysis and Design, chapter 2
- Math Training Institute use case diagram · Object Oriented Analysis and Design, chapter 2
- Event management system summary and class diagram · Object Oriented Analysis and Design, chapter 2
- ATM withdrawal sequence diagram · Object Oriented Analysis and Design, chapter 2
- Seconds section of a digital clock · Digital Logic, chapter 8
- Operation of a digital clock · Digital Logic, chapter 8
- JavaScript DOM and date-time function · Web Technology, chapter 4
- 8255 mode 2 operation with timing diagram · Instrumentation II, chapter 2
All Object Oriented Analysis and Design chapter 2 questions →