Skip to main content

Subsection 10.1.1 Part 1: How Many Pins Would You Need?

Figure 10.1.1 is the display we are going to drive: four digits, each with seven segments and a decimal point, plus a colon between the middle two. Before reading on, work out two numbers. How many LEDs are in this display? And if each one had its own pin on the STM32C031C6, how many pins would that take?
Figure 10.1.1. The four-digit seven-segment display used in this course, mounted on an Adafruit HT16K33 backpack and shown with every segment lit. Four digits of seven segments each, four decimal points and a two-dot colon come to 34 LEDs. (The colon’s two dots share a pin pair inside the display, so they always light together: 34 LEDs, 33 things you can switch.) The four header pins along the top edge, labeled +, −, D and C on the board, are the only connections it needs.
The count is 4 × 7 segments = 28, plus one decimal point per digit = 32, plus the colon’s two dots = 34 LEDs. One pin each, except the two dots in the colon, which share a pin, comes to 33 pins. The Nucleo’s Arduino headers carry 22 pins. More are available via the morpho connectors, but using up 33 pins is clearly not a viable solution.
We’ll wire the display with just four wires: power, ground, and the two wires of an I2C (Inter-Integrated Circuit) bus. A separate chip on the small board underneath the display, a backpack, takes commands from the STM32C0 over those two I2C wires via a special protocol and drives all 34 LEDs itself. We’ll talk about the I2C protocol today and will examine how to talk to the backpack chip tomorrow.