Skip to content
Arduino library for TM1637 (LED Driver)
Branch: master
Clone or download
Pull request Compare This branch is 3 commits ahead, 14 commits behind avishorp:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples/Led7SegmentTest
src
LICENSE
README.md
keywords.txt
library.properties

README.md

Led7Segment

An Arduino library for 7-segment display modules based on the TM1637 chip.

The library is based on TM1637Display (https://github.com/avishorp/TM1637): it retains the original low-level functions for communication with the TM1637 chip, but replaces or enhances the public methods.

Hardware Connection

The display module has signal connections CLK and DIO (besides power connections). These pins can be connected to any pair of digital pins on the Arduino. There is no limitation on the number of instances used concurrently (as long as each instance has a pin pair of its own).

Installation

Download the .zip file and install it using Sketch / Include Library / Add .ZIP Library in Arduino IDE. Alternatively, unzip the archive into directory sketches/libraries.

Usage

The library provides a class named Led7Segment with the following methods.

Led7Segment(pinClk, pinDio)
Initialize the display, enable it and set it to the highest brightness.
turnOn()
Turn the display on.
turnOff()
Turn the display off.
setBrightness(brightness)
Set the brightness (0 - 7). The change takes effect immediately.
clearDisplay(pos=0, length=4, zeros=false)
Clear the display or a part of a given length starting from pos (0 is the leftmost digit). If zeros is set to true, the display is filled with zeros instead of with blanks.
showNumber(number, pos=0, length=4, leading_zeros=false, base=10)
Show num starting at pos (0 being the left-most digit) and using length digits. The number is right-aligned; if leading_zeros is set to true, the number is left-padded with zeros. If pos + length >= 4, length is decreased accordingly.

If the number (including the minus sign, when needed) does not fit into length, E's are shown instead of the number.

Base must be between 2 (binary) and 16 (hexadecimal).

setDots(mask)
Set dots at the places corresponding to the four right-most bits. For displays with a single colon at the middle, setDots(4) shows the colon and setDots(0) hides it.
setSegments(data[], pos, length)
Set length digits starting from pos with the given data, which contains one byte per digit, with one bit per segment. The library defines constants SEG_T, SEG_TR, SEG_BR, SEG_B, SEG_BL, SEG_TL, SEG_M and SEG_D with values 1, 2, 4, 8, ... 128 which correspond to bits representing the top, top-right, bottom-right, bottom, bottom-left, top-left, middle segment, and the dot, respectively. E.g. donE can be shown with setSegment(done); where done is
uint8_t done[] = {
    SEG_TR | SEG_BR | SEG_B | SEG_BL | SEG_M,  // d
    SEG_BR | SEG_B | SEG_BL | SEG_M,           // o
    SEG_BR | SEG_BL | SEG_M,                   // n
    SEG_TL | SEG_BL | SEG_T | SEG_M | SEG_B    // E
};
You can’t perform that action at this time.