Arduino Mega - TM1637 4-Digit 7-Segment Display
For projects like clocks, timers, and counters, you use a normal 4-digit 7-segment display. Usually, it needs 12 wires. But the TM1637 module makes it easier by using only 4 wires: two wires for power and two wires to control the segments.
This guide won't go into hardware details. We'll show how to connect a 4-digit seven-segment display to the Arduino Mega and how to program it to show what we want.

This guide uses a 4-digit, colon-separated 7-segment display. If you need to show decimal numbers, please use the 74HC30 4-digit 7-segment Display Module.
Hardware Preparation
| 1 | × | Arduino Mega | |
| 1 | × | USB 2.0 cable type A/B (for USB-A PC) | |
| 1 | × | USB 2.0 cable type C/B (for USB-C PC) | |
| 1 | × | TM1637 4-digit 7-segment Display (colon-separated) | |
| 1 | × | Jumper Wires |
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (30 sensors/displays) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of TM1637 4-digit 7-segment Display
A TM1637 module usually has four 7-segment LED displays and a colon LED between them. It can show time as hours and minutes, or minutes and seconds, or the scores of two teams.
Pinout
The TM1636 four-digit seven-segment display module has four pins.
- CLK pin: Clock pin. You can connect it to any digital pin on the Arduino Mega.
- DIO pin: Data pin (input/output). Connect it to any digital pin on the Arduino Mega.
- VCC pin: Power pin. It gives power to the module. Connect it to a 3.3V or 5V supply.
- GND pin: Ground pin. Connect it to the ground.

Wiring Diagram
To connect a TM1637 display to an Arduino Mega, you need four wires: two for power and two for control. Power the module from the Mega’s 5V pin. Connect the CLK and DIO pins to any digital pins on the Mega, like 2 and 3. If you use different pins, remember to update the pin numbers in the code.

This image is created using Fritzing. Click to enlarge image
Library Installation
To use the TM1637 4-digit 7-segment display easily, you need to install the TM1637Display library by Avishay Orpaz. Here are the steps to install the library:
- Open the Libraries icon on the left side of the Arduino IDE.
- Type TM1637 in the search box and find the TM1637Display library by Avishay Orpaz.
- Click the Install button.

How To Program For TM1637 4-digit 7-segment using Arduino Mega
- Add the library
- Connect the Arduino Mega to the display using D9 as CLK and D10 as DIO.
- Create a display item named TM1637Display.
- You can show:
- A number
- A decimal number
- A negative number
- Or a letter
- If you use a letter, say how it looks. Here are examples for each case:
- To show a number, see the examples below.
- The symbol _ (underscore) means a digit that is not shown.
- Show the number using a colon or a period.
Arduino Mega Code
Detailed Instructions
Follow these steps one by one.
- Connect a TM1637 4-digit 7-segment display to the Arduino Mega using the provided diagram.
- Connect the Arduino Mega board to your computer with a USB cable.
- Open the Arduino IDE on your computer.
- Choose the right board (Arduino Mega) and the correct COM port.
- Copy the code above and paste it into the Arduino IDE.
- Click the Upload button in the Arduino IDE to upload the code to the Arduino Mega.
- Watch the states of the 7-segment display.