TM1651 LED controller (28 LEDs max), Keyboard scan (7 keys max)

Titan Microelectronics TM1651 LED controller supports 4 Digits @ 7 Segments. Also supports a scanned keyboard of upto 7 keys. Serial bus interface.

Hello World

Import programmbed_TM1651

Test for TM1651 LED controller library Initial version, Battery monitor


Import libraryTM1651

Library for TM1651 LED controller Initial version, Battery monitor




This LED driver is found in frontpanel controllers of consumer electronics such as DVD players. The added features such as the keyboard scanning are useful in these applications. The typical application schematic is shown below.


The TM1651 has a Clock pin and a single pin for Data input (commands, LED segments) and Data output (key status). This pin can be connected to mbed DigitalInOut pins. The protocol is ''I2C like'', but not identical.

The example code was tested on the Open-Smart Battery monitor module (Aliexpress). This modules has a 10 segment display with some segments connected in parallel to the same TM1651 driver pin. The module does not have any switches.


The lib supports methods to set or clear individual LEDs (i.e. setIcon() and clrIcon() ). The battery level can be set at 7 different values (see setLevel() ). There are also methods to set the brightness at 8 different levels and to turn the display on or off.

Note that you can also find TM1651 modules on ebay or Aliexpress with 4 digits of 7 segments. These are not yet supported by the lib. Such a module would need a new class that inherits from the base class TM1651 and is extended to support 7-segment digits.

Select the target module by enabling one of the #defines in TM1651_Config.h

// Select one of the testboards for TM1638 LED controller
#define TM1651_TEST  0

Note that the TM1651 is very similar to other LED controllers of the same vendor (eg TM1637).

You need to log in to post a discussion