Week 9 ยท Integration & Task C
Session 42: Real-time clock and fixed-width text
Learning outcomes
- Share one I2C bus between the RTC and the LCD
- Set the RTC once and read hours, minutes and seconds
- Show the date and time with snprintf padding
- Explain why millis() is not a wall clock
Kit and components
- Uno, DS1307 RTC module with backup cell, I2C LCD, breadboard
Pre-reading about 20 min
Students read these on their phones before class. They are listed on the student Before class page.
Session plan
- 0:0010 minRecap
Quiz: DHT11
- 0:1020 minDemo
Setting the time safely
Set the RTC from the compile time once, then comment the line out and re-upload so a reset does not overwrite the clock.
- 0:3040 minBuild
Clock on the LCD
Students run the worked sketch, then show HH:MM:SS on row 1 and DD/MM/YYYY on row 2 using their formatDate() function.
- 1:1035 minCode Along
Formatting practice
- 1:4515 minWrap-up
Power off, power on
Unplug the Uno for a minute and confirm the RTC kept time.
Checkpoint: ready to move on?
Students' LCD shows the correct time and date from the RTC, and it survives a power cycle.
Extension for fast finishers
Start the clock and alarm capstone (extension lesson) with an alarm time and a buzzer.
Catch-up path
Show the time on Serial before moving it to the LCD.
Homework and practice
Read the Task C brief and draft success criteria for each subsystem.
Facilitator notes
- A sketch that sets the RTC on every start-up resets the clock on every reset - the lesson's Set time only when needed section explains the fix.