TM1637 LED controller (48 LEDs max), Keyboard scan (16 keys max)
Titan Microelectronics TM1637 LED controller supports 6 Digits @ 8 Segments. Also supports a scanned keyboard of upto 16 keys. Serial bus interface.
This LED driver is found in frontpanel controllers of consumer electronics such as DVD players. The added features such as the matrix keyboard scanning are useful in these applications. The typical application schematic is shown below.
The TM1637 has a single pin for Data input (commands, LED segments) and Data output (key status). This pin can be connected to mbed MOSI and MISO using a series/pull-up resistor. The device also needs an SCK pin. The protocol is ''I2C-like'', but not compatible to I2C (very strange, uses commands instead of address+RW bits, you could not have more than one device on the same bus since the I2C address is not used). The initial version of the library implemented a bit-banged serial protocol to control the TM1637 using three pins (MOSI, MISO, SCK). The wiring is shown below. Note that any DigitalOut and DigitalIn pin will work. You don't need to use the pins dedicated to SPI.
The second and higher releases of the library use a single DigitalInOut pin instead of two separate pins for MOSI and MISO. The new wiring example is shown below. Note that any DigitalInOut pin will work. You don't need to use the pins dedicated to SPI.
Note that the Constructor for the 3 pin interface is now deprecated, but still supported for the initial example code. You may fully disable that constructor by modifying the corresponding #define in TM1637_Config.h
The example code was tested on the CATALEX module (less than $3 on Aliexpress). This modules has 4 seven segment displays without decimal point, a colon and no switches. A few switches were added using flying wires to test the readKey() functionality.
The CATALEX module seems to be a clone of the the Grove Seeed module.
The library supports printf() style methods to display int, hex and float. Icons may be set and cleared, cursor locate, display clear and brightness setting are available, keys can be read back and tested.
There are also other 4 digit display modules similar to the CATALEX that have decimal points instead of the ''colon''. These will work as well, allowing you to display floating point values.
The example code was also tested on the ROBOTDYN 6 Digit modules (e.g. Aliexpress, also available for different sizes of displays). See below.
The library also supports a 6 Digit module with 6 switches (e.g. Aliexpress, search for EYEWINK). This module has breakout pins to add another 8 switches (so upto 14 out of the 16 that are supported ). See below.
Select the target module by enabling one of the #defines in TM1637_Config.h
// Select one of the testboards for TM1637 LED controller #define TM1637_TEST 0 #define CATALEX_TEST 0 #define ROBOTDYN_TEST 0 #define EYEWINK_TEST 1
The proper target module needs to be selected because there are some hardware differences between the modules.