Introduction
The TM1637 4-digit 7-segment LED display is a commonly used module with Arduino boards for displaying numerical data. This display module is affordable and easy to use, making it popular among hobbyists and professionals alike. With its four-digit display and seven-segment design, it can display numbers, letters, and other symbols, making it an excellent choice for projects that require data visualization.
In this article, we will explore how to use the “TM1637 4-digit 7-segment LED display” with Arduino and provide examples of how it can be utilized in various projects.
What is TM1637 4-Digit 7-Segment LED Display?
TM1637 4-Digit 7-Segment LED Display is a simple, cost-effective, and easy-to-use display module that consists of four 7-segment LED displays arranged in a row, and a driver IC TM1637. The display can be used to display numerical values, and it can be easily interfaced with a microcontroller like Arduino. It uses a two-wire interface to communicate with the microcontroller, and the TM1637 IC takes care of driving the LEDs and multiplexing the display.
Hardware Components
To interface a TM1637 4-Digit 7-Segment LED Display with Arduino, you’ll need the following hardware components to get started:
Components | Value | Qty |
---|---|---|
Arduino UNO | – | 1 |
USB Cable Type A to B | – | 1 |
DC Power for Arduino | – | 1 |
7-segment LED display | TM1637 | 1 |
Jumper Wires | – | 1 |
TM1637 4-Digit 7-Segment LED Display Pinout
Pin Name | Pin Description |
---|---|
VCC | pin supplies power to the module. Connect it to the 3.3V to 5V power supply |
GND | GND is the ground pin |
CLK | clock input pin. Connect to any digital pin on Arduino. |
DIO | Data I/O pin. Connect to any digital pin on Arduino |
TM1637 4-Digit 7-Segment LED Display Circuit
Make connections according to the circuit diagram given below.
Wiring / Connections
Arduino | 7-Segment LED Display |
---|---|
5V | VCC |
GND | GND |
D3 | DIO |
D2 | CLK |
Installing Arduino IDE
First, you need to install Arduino IDE Software from its official website Arduino. Here is a simple step-by-step guide on “How to install Arduino IDE“.
Installing Libraries
Before you start uploading a code, download and unzip the following libraries at /Program Files(x86)/Arduino/Libraries (default), in order to use the sensor with the Arduino board. Here is a simple step-by-step guide on “How to Add Libraries in Arduino IDE“.
Code
Now copy the following code and upload it to Arduino IDE Software.
// Include the library:
#include <TM1637Display.h>
// Define the connections pins:
#define CLK 2
#define DIO 3
// Create display object of type TM1637Display:
TM1637Display display = TM1637Display(CLK, DIO);
// Create array that turns all segments on:
const uint8_t data[] = {0xff, 0xff, 0xff, 0xff};
// Create array that turns all segments off:
const uint8_t blank[] = {0x00, 0x00, 0x00, 0x00};
// You can set the individual segments per digit to spell words or create other symbols:
const uint8_t done[] = {
SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d
SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, // O
SEG_C | SEG_E | SEG_G, // n
SEG_A | SEG_D | SEG_E | SEG_F | SEG_G // E
};
// Create degree Celsius symbol:
const uint8_t celsius[] = {
SEG_A | SEG_B | SEG_F | SEG_G, // Circle
SEG_A | SEG_D | SEG_E | SEG_F // C
};
void setup() {
// Clear the display:
display.clear();
delay(1000);
}
void loop() {
// Set the brightness:
display.setBrightness(7);
// All segments on:
display.setSegments(data);
delay(1000);
display.clear();
delay(1000);
// Show counter:
int i;
for (i = 0; i < 101; i++) {
display.showNumberDec(i);
delay(50);
}
delay(1000);
display.clear();
delay(1000);
// Print number in different locations, loops 2 times:
int j;
for (j = 0; j < 2; j++) {
for (i = 0; i < 4; i++) {
display.showNumberDec(i, false, 1, i);
delay(500);
display.clear();
}
}
delay(1000);
display.clear();
delay(1000);
// Set brightness (0-7):
int k;
for (k = 0; k < 8; k++) {
display.setBrightness(k);
display.setSegments(data);
delay(500);
}
delay(1000);
display.clear();
delay(1000);
// Print 1234 with the center colon:
display.showNumberDecEx(1234, 0b11100000, false, 4, 0);
delay(1000);
display.clear();
delay(1000);
int temperature = 24;
display.showNumberDec(temperature, false, 2, 0);
display.setSegments(celsius, 2, 2);
delay(1000);
display.clear();
delay(1000);
display.setSegments(done);
while(1);
}
Code Explanation.
This Arduino code demonstrates how to interface the TM1637 4-Digit 7-Segment LED Display with the Arduino board and control the display using the TM1637Display library. The code first defines the pins to be used for the CLK and DIO connections and creates a display object of type TM1637Display. The code then defines various arrays of segment patterns to be displayed on the LED display, such as “data” and “blank“.
In the setup function, the display is cleared and a delay of 1000 milliseconds is added. In the loop function, various display functions are called to demonstrate different features of the LED display, such as setting the brightness, displaying numbers in different locations, showing a counter, and displaying temperature with the Celsius symbol.
Overall, the code is a great starting point for anyone who wants to learn how to use the TM1637Display library to control a 4-digit 7-segment LED display with an Arduino board.
Applications
Here are some common applications of the TM1637 4-Digit 7-Segment LED Display:
- Digital clocks and timers
- Temperature displays
- Counters and timers
- Speedometers and tachometers
- Scoreboards and game displays
- Data logging and monitoring systems
- Industrial automation and control panels
- DIY electronics projects and hobbyist applications
- Education and learning platforms for teaching electronics and programming
- Prototyping and testing applications where numerical values need to be displayed
Conclusion
The TM1637 4-digit 7-segment LED display is a versatile and user-friendly module that can be used in a wide range of projects. Whether you are working on a temperature sensor, a countdown timer, or any other project that requires numerical data to be displayed, the TM1637 display module can provide an easy and effective solution.