Week 7 · Displays & Signals

Session 34: Formatted text and an LCD dashboard

Teach & build120 minNo new lesson

Learning outcomes

  • Build fixed-width text with snprintf and %02d
  • Format floats with dtostrf, because %f does not work on the Uno
  • Update an LCD dashboard without flicker or leftover characters

Kit and components

  • Uno, I2C LCD, 10 kΩ potentiometer, push button, breadboard

Pre-reading about 25 min

Students read these on their phones before class. They are listed on the student Before class page.

  1. Theory Reference: C strings and char buffers
  2. Theory Reference: snprintf and format specs
  3. Theory Reference: Floats with dtostrf (AVR Uno)

Session plan

  1. 0:0010 min
    Recap

    Quiz: IR or I2C

  2. 0:1020 min
    Demo

    One buffer per row

    Show snprintf into a 17-character buffer, %02d padding, and %f printing a question mark on the Uno.

  3. 0:3045 min
  4. 1:1535 min
    Build

    LCD dashboard

    Row 1 shows the potentiometer as volts to two decimals with dtostrf; row 2 shows the uptime as HH:MM:SS and a button count, updated every 250 ms with millis().

  5. 1:5010 min
    Wrap-up

    Fixed width, no crumbs

Checkpoint: ready to move on?

Students' dashboard shows both rows at fixed widths with no leftover characters while the values change.

Extension for fast finishers

Catch-up path

Build row 2 of the dashboard only.

Homework and practice

Code Along 14.3 and 14.4.

Facilitator notes

  • Task B needs a temperature shown to 0.1 °C on the LCD - this session is the practice.