Before considering the code, we need to consider what we are trying to accomplish. Commands for the TM1638 consist of a command byte followed by zero or more data bytes. Sometimes the microcontroller sends the data, other times it receives data, and in either case there is a single data wire used (MOSI and MISO …
For my next book I wanted an example program that had the need for lots of 7-segment display digits, buttons, and LEDs. I found what I wanted, at a low cost, in one of these: This has 8 7-segment (plus decimal point) digits, 8 LEDs, and 8 push buttons, and used a three-wire SPI interface. …