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.

Hello World

Import programmbed_TM1637

Test program fro TM1637 LEDController Library, Initial release.

Library

Import libraryTM1637

Library for TM1637 LEDcontroller

Pinout

Notes

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.

/media/uploads/wim/853530-di2.gif

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.

/media/uploads/wim/serial_tm1637_sch.jpg

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.

/media/uploads/wim/dio-clk_serial_tm1637_sch.jpg

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.

/media/uploads/wim/tm1637-red-digital-tube-led-display-module-clock-2.jpg

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.

/media/uploads/wim/20170930_125406.jpg

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.

/media/uploads/wim/20171006_191727.jpg

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.

Note that the TM1637 is very similar to LED (eg TM1638) and VFD controllers (eg PT6312) by the same and other vendors. See here and here.