30 Days Lost in Space → Help Center

Libraries

TM1637: 7-Segment Display Driver

Control 4-digit 7-segment displays with just 2 pins. Display numbers, time, and simple text for counters and clocks.

What is TM1637?

The TM1637 is a driver IC for 4-digit 7-segment displays. It handles all the multiplexing internally, so you only need 2 pins (CLK and DIO) to control the display.

Installation

Search for "TM1637" by Avishay Orpaz in the Arduino Library Manager.

Setup

#include <TM1637Display.h>

#define CLK 2
#define DIO 3

TM1637Display display(CLK, DIO);

Key Functions

Display a number

display.showNumberDec(1234);         // Shows: 1234
display.showNumberDec(42);           // Shows:   42
display.showNumberDec(42, true);     // Shows: 0042 (leading zeros)

Display time (with colon)

display.showNumberDecEx(1230, 0b01000000);  // Shows: 12:30

Set brightness

display.setBrightness(0);   // Dimmest
display.setBrightness(7);   // Brightest

Display individual segments

uint8_t data[] = {
  SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F,  // 0
  SEG_B | SEG_C,                                       // 1
};
display.setSegments(data);

Show text-like characters

// "donE"
uint8_t done[] = {
  SEG_B | SEG_C | SEG_D | SEG_E | SEG_G,           // d
  SEG_C | SEG_D | SEG_E | SEG_G,                    // o
  SEG_C | SEG_E | SEG_G,                            // n
  SEG_A | SEG_D | SEG_E | SEG_F | SEG_G,           // E
};
display.setSegments(done);