Arduino Nano · TM1637 Display

Arduino Nano TM1637 Display Simulator: Wiring, Code and a Live Circuit

This is a TM1637 4-digit 7-segment display wired to an Arduino Nano, running a minutes and seconds clock live in your browser with the TM1637Display library.

Four wires: power, GND, CLK to pin 2 and DIO to pin 3. Two signal pins drive all 32 segments.

  • 5 V logic
  • Library: TM1637Display.h
  • CLK 2, DIO 3
  • Colon for a clock
Arduino Nano · TM1637 Displaylive0.000 s 0.00x
Click to open it in the editor
The circuit itself, running on the simulator with the sketch below. Press what can be pressed; click anything else to open it in the editor.

Wiring the TM1637 Display to the Arduino Nano

Every connection in the circuit above, with the board’s own pin names.

TM1637 Display pinArduino Nano pinWhy
VCC5VThe TM1637 runs from 3.3 to 5 V; brighter at 5 V.
GNDGNDCommon ground.
CLKpin 2Clock. Any digital pin: it is not I2C, despite looking like it.
DIOpin 3Data, both directions.

The module runs from 5V and its CLK and DIO lines idle at 5 V through the module’s pull-ups, the Arduino Nano’s own level.

Pins to leave alone on the Arduino Nano

A6 and A7 are analog only: pinMode(A6, OUTPUT) does nothing and digitalRead(A7) is not there to call. D0 and D1 are the USB serial port.

On a real bench

The Nano plugs into the breadboard itself, straddling the center channel, so the TM1637 Display goes in a few columns along and every connection is a short jumper. The silkscreen labels its pins D2 to D13 and A0 to A7; in code D2 is simply 2. A Nano clone with a CH340 USB chip needs that driver on a real computer.

The code

The sketch the circuit above runs. Open it in the editor, change a line and press Run: it compiles in your browser.

TM1637 clock on Arduino Nano
#include <TM1637Display.h>

const int CLK_PIN = 2;   // pin 2
const int DIO_PIN = 3;   // pin 3

TM1637Display display(CLK_PIN, DIO_PIN);

void setup() {
  Serial.begin(9600);
  display.setBrightness(4);         // 0 to 7
  Serial.println("Counting");
}

void loop() {
  // Minutes and seconds since reset, with the colon on.
  unsigned long s = millis() / 1000;
  int mmss = (s / 60) % 100 * 100 + s % 60;
  display.showNumberDecEx(mmss, 0b01000000, true);
  delay(200);
}

TM1637Display display(CLK_PIN, DIO_PIN) names the two pins. The TM1637 chip on the module scans the four digits itself, so the board only sends it a number when something changes.

showNumberDecEx(number, dots, leadingZeros) shows a number up to 9999. The dots mask 0b01000000 lights the colon between the second and third digits, and true keeps the leading zeros, so 1:05 shows as 01:05.

Serial.begin(9600) opens the serial monitor. Serial is the USB port, as on the Uno; a clone with a CH340 chip needs that driver on a real computer, which the simulator does not.

Common mistakes with the TM1637 Display on the Arduino Nano

Wiring CLK and DIO to the I2C pins

The protocol looks like I2C but is not; it has no address and the Wire library cannot talk to it. Any two digital pins work, and leaving pin A4 and pin A5 free keeps them for a real I2C part.

Expecting decimal points

Most TM1637 clock modules wire only the colon, not the dots under each digit. The dots argument lights them on modules that have them, and the colon on these.

Picking A6 or A7

A6 and A7 look like the other analog pins but are inputs to the ADC and nothing else. CLK or DIO on either of them never sees a digital level. Any of D2 to D13 or A0 to A5 works.

Questions and answers

Can I simulate a TM1637 display with an Arduino Nano?

Yes. The circuit at the top of this page is an Arduino Nano with a TM1637 display, running in your browser on a simulated ATmega328P. The simulated module decodes the real two-wire protocol, so the digits and the colon show exactly what the library sent. Press Run it in the editor to change the wiring or the code; it is free and needs no account.

How do I show letters?

setSegments() takes a byte per digit, one bit per segment, so letters that fit a 7-segment shape (A, b, C, d, E, F and a few more) can be built by hand.

Can I show negative numbers?

showNumberDec() handles them down to -999, using the first digit for the minus sign.

What about a MAX7219 display?

It is a different chip on a three-wire SPI-style bus, driven with LedControl.h. The simulator has it too; the TM1637 is cheaper and needs one pin fewer.

Build your own TM1637 Display project

Open this circuit in the editor, change the wiring or the code, and keep your version in a free account.