Introduction
If you’ve ever wanted to display numbers in your Arduino
projects — whether it’s a clock, a counter, or sensor readings — the TM1637
4-digit 7-segment LED display is one of the easiest and most affordable
solutions. It uses only two data pins, thanks to the onboard TM1637 driver IC,
which simplifies wiring and coding compared to traditional 7-segment displays.
In this blog, we’ll walk through:
- Understanding
the TM1637 module
- Pinout
and wiring with Arduino Uno
- Installing
the required library
- Example
codes (basic display, scrolling, countdown, sensor integration)
- Practical
applications and project ideas
- Troubleshooting
and tips
Understanding the TM1637 Module
The TM1637 module is widely available in electronics shops
and online marketplaces. Here’s what makes it special:
- 4-digit
7-segment LED display: Each digit can show numbers 0–9 and some
letters.
- Colon
separator: Useful for clocks and timers.
- TM1637
driver IC: Handles multiplexing and communication, reducing pin usage.
- Two-wire
interface: Only requires CLK and DIO pins, plus VCC and GND.
Pinout
- VCC
→ 5V
- GND
→ Ground
- DIO
→ Data I/O
- CLK
→ Clock
Wiring TM1637 with Arduino Uno
Here’s the wiring diagram:
|
TM1637 Pin |
Arduino Uno Pin |
|
VCC |
5V |
|
GND |
GND |
|
DIO |
Digital Pin 2 |
|
CLK |
Digital Pin 3 |
You can change the DIO and CLK pins in your code if needed.
Installing the TM1637 Library
- Open
Arduino IDE.
- Go
to Sketch → Include Library → Manage Libraries.
- Search
for TM1637Display.
- Install
the library by Avishay Orpaz (commonly used).
Example Codes
1. Basic Number Display
#include <TM1637Display.h>
#define CLK 3
#define DIO 2
TM1637Display
display(CLK, DIO);
void setup() {
display.setBrightness(0x0f); // Max brightness
}
void loop() {
display.showNumberDec(1234); // Display 1234
delay(2000);
}
2. Countdown Timer
#include <TM1637Display.h>
#define CLK 3
#define DIO 2
TM1637Display
display(CLK, DIO);
void setup() {
display.setBrightness(0x0f);
}
void loop() {
for (int i = 30; i
>= 0; i--) {
display.showNumberDec(i, true); // Show with leading zeros
delay(1000);
}
}
3. Scrolling Text (HELLO)
#include <TM1637Display.h>
#define CLK 3
#define DIO 2
TM1637Display
display(CLK, DIO);
const uint8_t
SEG_HELLO[] = {
SEG_H, SEG_E, SEG_L, SEG_L, SEG_O
};
void setup() {
display.setBrightness(0x0f);
}
void loop() {
for (int i = 0; i <
5; i++) {
display.showNumberDecEx(0,
0, true, 4, i); // Scroll effect
display.setSegments(SEG_HELLO + i, 4, 0);
delay(500);
}
}
4. Sensor Integration (Temperature Display)
If you connect a temperature sensor like DHT11, you
can display readings:
#include <TM1637Display.h>
#include <DHT.h>
#define CLK 3
#define DIO 2
#define DHTPIN 4
#define DHTTYPE DHT11
TM1637Display display(CLK, DIO);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
display.setBrightness(0x0f);
dht.begin();
}
void loop() {
int temp =
dht.readTemperature();
display.showNumberDec(temp);
delay(2000);
}
Applications
- Digital
Clock: Combine with RTC module (DS3231).
- Stopwatch/Timer:
Great for labs, cooking, or sports.
- Scoreboard:
Display scores in games.
- Sensor
Readouts: Show temperature, distance, or voltage.
- Counter
Projects: People counter, product counter, etc.
Troubleshooting
- No
display? Check wiring and ensure VCC is 5V.
- Dim
display? Adjust brightness with setBrightness().
- Wrong
numbers? Verify DIO and CLK pin assignments in code.
- Library
errors? Ensure you installed the correct TM1637Display library.
Conclusion
The TM1637 4-digit 7-segment LED display is a
powerful yet simple module for Arduino projects. With just two pins, you can
build clocks, timers, counters, and sensor displays. Its versatility makes it
perfect for beginners and advanced makers alike.
