Skip to content
Ricardo Batista edited this page Jul 6, 2016 · 2 revisions

TM1638/TM1640 library

This is a library for interacting an arduino with a TM1638/TM1640 module.

The TM1638 module is a module with 8x 7-segment display (8 digits), 8x 2 color (red and green) LED and 8x buttons and is controlled using serial commands.

The TM1638 module is designed to be chainable. It uses only one pin for clock, one pin for data and an additional pin (strobe) for each module you chain up to 6... that's a total of 8 pins for controlling 48 (8x6) 7-segment digits, 48 buttons and 96 LEDs (48 red and 48 green).

Great to use as a "helper/debugging" module.

The TM1640 module is a module with 16x 7-segment display (8 digits) and is controlled using serial commands.

Usage

This library is designed to allow usage of simultaneous independent modules (chained or unchained).

Basic usage is (after including "TM1638.h"):

TM1638 module(8, 9, 7);

This defines a module with data on pin 8, clock on pin 9 and strobe on pin 7.

Chaining modules is as easy as:

TM1638 module1(8, 9, 7);
TM1638 module2(8, 9, 6);

This defines two modules with data on pin 8, clock on pin 9 and strobes on pin 6 and 7.

There is also support for inverted TM1638 modules. They are used just like regular TM1638 and can be instantiated (after including "InvertedTM1638.h") with:

InvertedTM1638 module(8, 9, 7);

The TM1640 modules are used just like regular TM1638 and can be instantiated (after including "TM1640.h") with:

TM1640 module(8, 9);

Library Reference

Full Reference

Constructors

Default Constructor

Methods

Method Description
clearDisplay Clears the display. (TM1638/TM1640)
clearDisplayDigit Clear a single 7-segment display. (TM1638/TM1640)
getButtons Returns the pressed buttons as a bit set (left to right). (TM1638)
setDisplay Set the 7-segment displays to the 8 values (left to right). (TM1638/TM1640)
setDisplayDigit Set a single display to a digit. (TM1638/TM1640)
setDisplayToBinNumber Set the display to a binary number. (TM1638)
setDisplayToDecNumber Set the display to a unsigned decimal number, with or without leading zeros. (TM1638)
setDisplayToSignedDecNumber Set the display to a signed decimal number, with or without leading zeros. (TM1638)
setDisplayToError Set the display to an error message. (TM1638/TM1640)
setDisplayToHexNumber Set the display to a unsigned hexadecimal number, with or without leading zeros. (TM1638)
setDisplayToString(char*) Set the display to the string. (TM1638/TM1640)
setDisplayToString(String) Set the display to the string. (TM1638/TM1640)
setLED Controls a LED. (TM1638)
setLEDs Set all the LEDs. (TM1638)
setupDisplay Set the display (all 7-segments) and LEDs on or off and the specifies the intensity. (TM1638/TM1640)
Clone this wiki locally