Arduino Nano - TM1637 4-Digit 7-Segment Display

This walkthrough takes you step by step through using a TM1637 4-digit 7-segment display module with the Arduino Nano. The Nano packs the same ATmega328P as the Uno into a compact, breadboard-friendly form factor - great for tight builds and prototyping where space matters.

What you will walk through:

Arduino Nano TM1637 4-Digit 7-Segment Display

Hardware Preparation

1×Official Arduino Nano
1×Alternatively, DIYables Nano V3.0 Development Board
1×USB A to Mini-B USB cable
1×TM1637 4-digit 7-segment Display (colon-separated)
1×Jumper Wires
1×Breadboard
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

What Is the TM1637 Display Module?

The TM1637 is a driver chip designed for 7-segment LED displays. It takes care of digit multiplexing internally and communicates with the microcontroller over just two wires - CLK and DIO. The chip has its own display memory, so once you write data to it, the display holds steady without any refresh loop in your code.

What the module provides:

  • 4 digits, each with 7 segments plus a decimal point
  • Colon separator between the second and third digit for clock-style display
  • 8 brightness levels you can set through code
  • 2-wire interface compatible with 3.3V and 5V
  • Built-in display memory - set it and forget it

Pin Mapping

Function Pin
CLK Clock signal input
DIO Data input/output
VCC Power supply (3.3V or 5V)
GND Ground

CLK and DIO can go to any digital pins on the Nano. The examples below use pins D2 and D3.

Wiring Diagram

Wire the TM1637 module to the Arduino Nano:

  • CLK to pin 9
  • DIO to pin 10
  • VCC to 5V
  • GND to GND
The wiring diagram between Arduino Nano and TM1637 4-Digit 7-Segment Display

This image is created using Fritzing. Click to enlarge image

See The best way to supply power to the Arduino Nano and other components.

Setting Up the Library

  1. Plug the Arduino Nano into your computer with a Mini-B USB cable.
  2. Open Arduino IDE. Set the board to Arduino Nano and select the matching port.
  3. Go to the Libraries panel on the left.
  4. Type "DIYables_4Digit7Segment_TM1637" in the search box. Look for the library from DIYables.
  5. Click Install.
Arduino TM1637 4-Digit 7-Segment Display library

The library is self-contained - no extra dependencies to install.

Note: If your Nano uses an older bootloader, select ATmega328P (Old Bootloader) under Processor in the Tools menu.

Foundation Code

Every sketch built with the DIYables_4Digit7Segment_TM1637 library starts from this foundation:

#include <DIYables_4Digit7Segment_TM1637.h> #define CLK_PIN 9 #define DIO_PIN 10 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { display.begin(); display.print(1234); } void loop() { }

Pass the CLK and DIO pin numbers to the constructor, call begin() once in setup(), and the display is ready for data.

Arduino Nano Code - Display Integer Numbers

This example walks through displaying various integer values, including negative numbers and zero-padded output.

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-tm1637-4-digit-7-segment-display */ /* * DIYables_4Digit7Segment_TM1637 - Integer Example * * Displays various integer values on a 4-digit 7-segment display * with TM1637 driver, including zero-padded numbers. * * Tutorial: https://diyables.io/products/4-digit-7-segment-display-led-tm1637-with-colon * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4B Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables Nano R3: https://diyables.io/nano-board * - DIYables ESP32 Board: https://diyables.io/esp32-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_4Digit7Segment_TM1637.h> // Pin configuration - change to match your wiring #define CLK_PIN 9 #define DIO_PIN 10 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { Serial.begin(9600); display.begin(); Serial.println("TM1637 Integer Example"); } void loop() { // Display various integers int numbers[] = {0, 42, 1234, -5, -123, 9999}; int count = sizeof(numbers) / sizeof(numbers[0]); for (int i = 0; i < count; i++) { display.print(numbers[i]); Serial.print("Displaying: "); Serial.println(numbers[i]); delay(2000); } // Display with zero padding display.print(42, true); // Shows "0042" Serial.println("Displaying: 0042 (zero-padded)"); delay(2000); }

Follow Along

  • Wire the TM1637 module to the Nano as shown in the wiring diagram above.
  • Connect the Nano to your computer with a Mini-B USB cable.
  • Open Arduino IDE, pick the board and port, paste the code, and click Upload.
  • Open the Serial Monitor to view the output.

The display will cycle through the numbers 0, 42, 1234, -5, -123, 9999, and then show 42 with zero-padding as "0042".

Method Overview

Method Explanation Call Example
print(int) Display an integer (-999 to 9999) display.print(1234)
print(int, true) Display with leading zeros display.print(42, true)
clear() Clear the display display.clear()

Arduino Nano Code - Display Text and Temperature

This example walks through displaying text strings and formatted temperature with the degree symbol.

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-tm1637-4-digit-7-segment-display */ /* * DIYables_4Digit7Segment_TM1637 - TextAndDegree Example * * Displays text strings, special characters, and temperature * on a 4-digit 7-segment display with TM1637 driver. * * Tutorial: https://diyables.io/products/4-digit-7-segment-display-led-tm1637-with-colon * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4B Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables Nano R3: https://diyables.io/nano-board * - DIYables ESP32 Board: https://diyables.io/esp32-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_4Digit7Segment_TM1637.h> // Pin configuration - change to match your wiring #define CLK_PIN 9 #define DIO_PIN 10 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { Serial.begin(9600); display.begin(); Serial.println("TM1637 Text and Degree Example"); } void loop() { // Display text strings const char* texts[] = {"HELP", "Hi", "COOL", "done"}; for (int i = 0; i < 4; i++) { display.print(texts[i]); Serial.print("Displaying: "); Serial.println(texts[i]); delay(2000); } // Display temperature with degree symbol display.printTemperature(25, 'C'); // Shows "25°C" Serial.println("Displaying: 25 degrees C"); delay(2000); display.printTemperature(72, 'F'); // Shows "72°F" Serial.println("Displaying: 72 degrees F"); delay(2000); // Display string with degree constant char buf[5]; buf[0] = '2'; buf[1] = '5'; buf[2] = DIYables_4Digit7Segment_TM1637::DEGREE; buf[3] = 'C'; buf[4] = '\0'; display.print(buf); // Same as printTemperature(25, 'C') Serial.println("Displaying: 25 degrees C (via print)"); delay(2000); }

Follow Along

  • Wire the TM1637 module as shown above.
  • Upload the sketch and open the Serial Monitor.

The display cycles through "HELP", "Hi", "COOL", "done", then shows temperatures "25°C" and "72°F".

Method Overview

Method Explanation Call Example
print(const char*) Display a text string (up to 4 chars) display.print("HELP")
printTemperature(int, char) Display temperature with degree and unit display.printTemperature(25, 'C')
DEGREE Degree symbol constant display.DEGREE

Arduino Nano Code - Display Time with Blinking Colon

This example walks through showing a clock-like time with the colon blinking every 500 milliseconds.

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-tm1637-4-digit-7-segment-display */ /* * DIYables_4Digit7Segment_TM1637 - Time Example * * Displays time in HH:MM format with blinking colon separator * on a 4-digit 7-segment display with TM1637 driver. * * Tutorial: https://diyables.io/products/4-digit-7-segment-display-led-tm1637-with-colon * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4B Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables Nano R3: https://diyables.io/nano-board * - DIYables ESP32 Board: https://diyables.io/esp32-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_4Digit7Segment_TM1637.h> // Pin configuration - change to match your wiring #define CLK_PIN 9 #define DIO_PIN 10 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); int hours = 12; int minutes = 30; bool colonOn = true; void setup() { Serial.begin(9600); display.begin(); Serial.println("TM1637 Time Example"); Serial.println("Displaying 12:30 with blinking colon"); } void loop() { display.printTime(hours, minutes, colonOn); delay(500); // Toggle colon every 500ms for blinking effect colonOn = !colonOn; }

Follow Along

  • Wire the module, upload the code.
  • The display shows "12:30" with the colon blinking on and off.

Method Overview

Method Explanation Call Example
printTime(int, int) Display time HHMM with colon display.printTime(12, 30)
printTime(int, int, bool) Display time, control colon on/off display.printTime(12, 30, false)

Arduino Nano Code - Individual Digit Control

This example walks through setting each digit separately with numbers, characters, and the colon.

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-tm1637-4-digit-7-segment-display */ /* * DIYables_4Digit7Segment_TM1637 - IndividualDigits Example * * Sets individual digits, characters, and colon on a 4-digit * 7-segment display with TM1637 driver. * * Tutorial: https://diyables.io/products/4-digit-7-segment-display-led-tm1637-with-colon * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4B Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables Nano R3: https://diyables.io/nano-board * - DIYables ESP32 Board: https://diyables.io/esp32-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_4Digit7Segment_TM1637.h> // Pin configuration - change to match your wiring #define CLK_PIN 9 #define DIO_PIN 10 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { Serial.begin(9600); display.begin(); Serial.println("TM1637 Individual Digits Example"); } void loop() { // Set individual numbers on each digit position display.clear(); display.setNumber(0, 1); display.setNumber(1, 2); display.setNumber(2, 3); display.setNumber(3, 4); Serial.println("Displaying: 1234"); delay(2000); // Turn colon on display.setColon(true); Serial.println("Displaying: 12:34"); delay(2000); // Turn colon off display.setColon(false); Serial.println("Displaying: 1234"); delay(2000); // Set individual characters display.clear(); display.setChar(0, 'H'); display.setChar(1, 'E'); display.setChar(2, 'L'); display.setChar(3, 'P'); Serial.println("Displaying: HELP"); delay(2000); // Mix characters and numbers with colon display.clear(); display.setChar(0, 'A'); display.setNumber(1, 3); display.setChar(2, 'b'); display.setNumber(3, 7); display.setColon(true); Serial.println("Displaying: A3:b7"); delay(2000); // Blinking colon effect display.clear(); display.setNumber(0, 1); display.setNumber(1, 2); display.setNumber(2, 3); display.setNumber(3, 0); Serial.println("Blinking colon: 12:30"); for (int i = 0; i < 5; i++) { display.setColon(true); delay(500); display.setColon(false); delay(500); } delay(1000); }

Follow Along

  • Upload and watch the display cycle through different combinations.

Method Overview

Method Explanation Call Example
setNumber(int, int) Set a digit (0-9) at position 0-3 display.setNumber(0, 1)
setChar(int, char) Set a character at position 0-3 display.setChar(0, 'H')
setColon(bool) Turn colon on or off display.setColon(true)
setSegments(int, uint8_t) Set raw segments at position 0-3 display.setSegments(0, 0x76)

Troubleshoot

  1. Display shows nothing - Check the wiring. Make sure CLK and DIO are connected to the correct Nano pins and VCC goes to 5V.
  2. Wrong characters appear - CLK and DIO are likely swapped. Switch the two wires.
  3. Display too dim or too bright - Use setBrightness(level) with a value from 0 to 7.
  4. Compile error about missing library - Install DIYables_4Digit7Segment_TM1637 from the Arduino Library Manager.
  5. Upload fails with "not in sync" - Try selecting ATmega328P (Old Bootloader) in the Processor menu.

Platform Support

The library uses only Arduino standard APIs (pinMode, digitalWrite, digitalRead, delayMicroseconds) and works on all Arduino-compatible platforms.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!