Source: https://mokxi.com/libraries/tm1637
Updated: 2026-11-02

Libraries / Displays
Arduino library · Displays

# TM1637: four digits and a colon on two wires

The TM1637 module is the small four-digit display, red or blue, with a colon in the middle, sold for clocks and counters. A TM1637 chip on the back does the multiplexing, so the board only sends it what to show, over two wires named CLK and DIO.

Open the example in the editor See the calls

Built in on Mokxi: #include <TM1637Display.h> and it builds, with nothing to install. Free, and no account needed.

## What TM1637 does

Those two wires look like I2C but are not. The chip has no address and does not share a bus with other I2C devices, so it can go on any two digital pins and you give those pins to the constructor. Avishay Orpaz’s TM1637Display library, the one most tutorials include, handles the timing.

Two variants of the board exist: clock modules have the colon between the second and third digits and usually no decimal points, while others have a decimal point after each digit. Which one you have decides whether the dots argument of showNumberDecEx() lights a colon or a point.

Library Manager name | TM1637

Author | Avishay Orpaz

Include | #include <TM1637Display.h>

Boards | every board Mokxi compiles for

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | Four-digit display, TM1637

## Install it

It builds on every board Mokxi compiles for.

In Mokxi it is built in: #include <TM1637Display.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "TM1637" by Avishay Orpaz from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add TM1637 to lib_deps in PlatformIO. Mokxi follows the calls of release 1.2.0, so a sketch written here builds there too.

ESP32-C3 · Arduino Uno · Arduino Nano · Arduino Mega 2560 · Arduino Leonardo · SparkFun Pro Micro · Arduino Micro · ESP32-C6 · ATtiny85 · Raspberry Pi Pico · Raspberry Pi Pico W · Seeed XIAO SAMD21 · STM32 · STM32 Nucleo-F411RE · STM32 Blue Pill · micro:bit V2 · Arduino Uno R4 · ESP32 DevKit · ESP32-S3-DevKitC-1 · ESP8266 NodeMCU · Arduino Pro Mini 3.3 V · Seeed XIAO ESP32-C3 · ESP32-C3 SuperMini · Seeed XIAO ESP32-C6 · ESP32-DevKitC V4 · LOLIN32 Lite · Wemos D1 R32 · Cheap Yellow Display · TTGO T-Display · Seeed XIAO ESP32-S3 · Arduino Nano ESP32 · Arduino Nano RP2040 Connect · Seeed XIAO RP2040 · Waveshare RP2040-Zero · Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### TM1637Display display(CLK, DIO)

Creates the display on two pins, clock first. Any digital pins work.

### display.setBrightness(7)

Brightness from 0 to 7. A second argument of false turns the display off without losing what it shows.

### display.showNumberDec(1234)

Shows a whole number from -999 to 9999. showNumberDec(7, true) pads with leading zeros to show 0007.

### display.showNumberDecEx(1530, 0b01000000, true)

Like showNumberDec() with dots: on a clock module 0b01000000 lights the colon, so 1530 reads 15:30.

### display.setSegments(data)

Lights segments directly from an array of four bytes, one per digit, built from SEG_A to SEG_G, for letters and symbols.

### display.encodeDigit(5)

Returns the segment byte for a digit from 0 to 15, for mixing digits and symbols in one setSegments() call.

### display.clear()

Blanks all four digits.

## Example: Numbers on a four-digit display

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

### Wiring

- Arduino Uno R3 2 to Four-digit display, TM1637 CLK
- Arduino Uno R3 3 to Four-digit display, TM1637 DIO
- Arduino Uno R3 5V to Four-digit display, TM1637 VCC
- Arduino Uno R3 GND to Four-digit display, TM1637 GND

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### Nothing lights at all

CLK and DIO are swapped or on different pins from the constructor. The constructor takes the clock pin first; swap the two numbers or the two wires, and check the module has 5 V and ground.

### The colon never lights

showNumberDec() never lights it. Use showNumberDecEx() with 0b01000000 as the dots argument, and check the module is the clock kind, since some boards wire decimal points instead.

### Negative numbers or numbers over 9999 show wrong digits

Four digits hold -999 to 9999. Scale or clamp the value before showing it, or show the units with setSegments() when the number does not fit.

## Projects that use TM1637

Built-in projects that include it. Each page has the full sketch and opens in the editor, already wired.

Piggy bank A CH-926 coin acceptor counts each coin’s pulses on an interrupt, and a TM1637 display adds up the savings in dollars and cents. Pomodoro timer Twenty-five minutes of focus and five of rest on a four-digit display, with a red lamp for work, a green one for breaks and a chime at every change. Whack-a-mole Four lamps, four buttons, a piezo and a score display on an Uno: hit each mole before it ducks in a thirty-second round that speeds up as you score. H-pattern shifter and handbrake Two pots read an H-pattern gate with hysteresis and push-down reverse, two microswitches make sequential paddles and a hall sensor is the handbrake, with the gear on a display. Autopilot and landing gear panel An autopilot knob for heading, altitude and vertical speed on a four-digit display, an AP button, and a gear lever with three green lights and a red one in transit. Alarm clock A DS1302 keeps the time and a TM1637 shows it; at 7:00 a piezo beeps until the button stops it.

## Keep going

### Learn

- Arduino TM1637 Display: Library and Countdown
- Arduino DS3231 Clock With a TM1637 Display

### Parts

- Four-digit display, TM1637

### More displays libraries

- Adafruit SSD1306
- Adafruit GFX Library
- LiquidCrystal I2C
- LiquidCrystal
- LCD_I2C
- hd44780
- TFT_eSPI
- U8g2

Every built-in library · Open the editor

## Try TM1637 without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
