Use a 7-segment display to show digits on the microbit
This module will display 8 numerical digits on its display. Each digit is a 7-segment display comprised of 8 LEDs (7 for the number, and one for a decimal place).
It’s possible to drive each of these component LEDs either directly, or through a shift register. However, these modules use the
MAX7219 driver chip to simplify the process.
The microbit tells the
MAX7219 chip which number to display over SPI. The chip then displays the digit.
Like the HT1633 8x8 module on this site, the LED displays are connected to a backpack containing the
MAX7219 chip and wiring.
These 7-segment MAX7219 displays are available on eBay, Amazon and other sellers. Searching for
MAX7219 7-segment display reveals the components. They’re around £2 each.
Additionally, you will need a microbit breakout board to access the SPI pins of the microbit.
There are five wires to connect to the display module. Each of the pins do the following:
|CS / Chip Select||Goes low when data is being transmitted to the device. Goes high at the end of transmission. |
|DIN||Data transmitted over this wire.|
|CLK||Tells the microbit when to transmit data.|
Connect the module to the microbit and its edge connector as below. Be aware the pin labels can change dependning on the manufacturer:
|My Module Label||Possible Label Names||microbit Pin||Micropython Doc Names for pin|
|DIN||SOMI, SDI, DI, DIN, SI, MRST.||MISO (master in, slave out)|
|CS||nCS, CSN, nSS, STE, SYNC||n/a, but frequently called chip select|
DOUTpin. Ignore it!
To connect to these pins, you will need the microbit edge connector. Here’s my module wired up to my microbit:
Maxrix7seg module for the microbit from Github.. This contains the code used to communicate with the 7-segment display.
The module is imported in the header of your Python script:
Once your script is complete and has been flashed, the
matrix7seg module can be copied to the microbit:
/mu_code/directory, copy drag the
matrix7seg.pyfile across to the microbit.
It’s now possible to use the display module within the microbit:
.write_number() is used,
.show() must be used to update the display.
Published: December 23, 2016 Updated: December 23, 2016