TM1638 LED controller (80 LEDs max), Keyboard scan (24 keys max)

Titan Microelectronics TM1638 LED controller supports 8 Digits @ 10 Segments. Also supports a scanned keyboard of upto 24 keys. SPI bus interface.

Hello World

Import programmbed_TM1638

Test program for TM1638 LED controller. Supports LED&KEY, QYF-TM1638 and JY-LKM1638 module.

Library

Import libraryTM1638

TM1638 LED controller. Max 80 LEDs, Max 24 Key scan. Supports LED&KEY, QYF-TM1638 and JY-LKM1638 module.

Pinout

Datasheet

http://retrocip.cz/files/tm1638.pdf

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/appl_schema_new.jpg

The TM1638 has a single pin for Data input (commands, LED segments) and Data output (key status). This pin can be connected to mbed SPI MOSI and MISO using a series/pull-up resistor.

/media/uploads/wim/spi_pt6964_sch_-2-.jpg

The example code was tested on the LED&KEY module (less than $3 on Aliexpress). This modules has 8 seven segment displays with decimal point, 8 LEDs and 8 switches.

/media/uploads/wim/img_3993.jpg

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. Segment displays are available in different formats. The best known is 7-Segment, which is supported by the TM1638. Displays with more segments per digit are more suited to show characters and symbols. These are available with 14 or 16 segments.

/media/uploads/wim/segment_and_matrix.jpg

However, with some compromising even a 7 segment display can represent most characters reasonably well.

/media/uploads/wim/ascii_on_7_segments.jpg

The device is widely available on several modules that are sold on ebay or Aliexpress. Here are some other modules that are also supported by the library:

QYF-TM1638 (8 seven-segments + DP, 16 switches)

/media/uploads/wim/tm1638_a.jpg

JY-LKM1638 (8 seven-segments + DP, 8 Bi-Color LEDS, 8 switches)

/media/uploads/wim/tm1638_b.jpg

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

// Select one of the testboards for TM1638 LED controller
#define TM1638_TEST  0
#define LEDKEY8_TEST 1 
#define QYF_TEST     0 
#define LKM1638_TEST 0 

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


You need to log in to post a discussion

Discussion topics

TopicRepliesLast post
TM1638Lite 0 29 Mar 2018 by Danny Ayers