This project shows you how to make a digital clock using a TM1637 4-digit 7-segment display with Arduino. This display is excellent for showing time. For more details, watch the video below or read the written tutorial below.
Components for the TM1637 4-Digit Display Clock
Arduino Uno | × 1 | Amazon |
TM1637 4-digit 7-segment display | × 1 | Amazon |
DS3231 | × 1 | Amazon |
Breadboard | × 1 | Amazon |
Jumper wires kit | × 1 | Amazon |
USB cable type A/B | × 1 | Amazon |
Software
TM1637 4-Digit 7-Segment Display
The module is a special LED (light-emitting diode display) drive control circuit with a keyboard scan interface that is internally integrated with MCU digital interface, data latch, LED high-pressure drive, and keyboard scan.
TM1637 4-Digit 7-Segment Display Specifications
Operating voltage | 3.3V – 5.5V |
Operating current consumption | 80mA |
Operating temperature | -10ºC to +80ºC |
Display dimensions | 30 x 14 mm (0.36″ digits) |
Overall dimensions | 42 x 24 x 12 mm |
Cost | Check price |
This IC is made by Titan Micro Electronics. For more information, you can check out the datasheet below:
DS3231
The DS3231 is a low-cost, very precise I2C real-time clock (RTC) with a TCXO and crystal integrated compensating temperature. The device has a battery input which keeps the time when the device’s key energy is disrupted. The incorporation of the crystal resonator increases the device’s long-term precision and lowers component count in a production line. The DS3231 is sold in a 16-pin 300-mile SO kit and is available in commercial or industrial temperature ranges.
- RTC counts seconds, minutes, hours, and year
- Accuracy: +2ppm to -2ppm for 0ºC to +40ºC , +3.5ppm to -3.5ppm for -40ºC to +85ºC
- Digital temperature sensor with ±3ºC accuracy
- Two Time-of-day alarms
- Programmable square-wave output
- 400Khz I2C interface
- Low power consumption
- Automatic power failure battery switch circuitry
- CR2032 battery backup with two to three-year life
DS3231 Specifications
Operating voltage | 2.3V – 5.5V |
Operating current consumption | 70 – 150 µA |
Operating temperature | 40°C to +85°C |
Cost | Check price |
The DS3231 IC is made by Maxim Integrated. For more information, you can check out the DS3231 datasheet below:
TM1637 4-Digit Display Clock Circuit Schematics


SDA and SCL Connections
Board | I2C / TWI pins |
Uno, Ethernet | A4 (SDA), A5 (SCL) |
Mega2560 | 20 (SDA), 21 (SCL) |
Leonardo | 2 (SDA), 3 (SCL) |
Due | 20 (SDA), 21 (SCL), SDA1, SCL1 |
TM1637 Display Connections
TM1637 4-Digit Display | Arduino |
VCC | 5 V |
GND | GND |
CLK | Digital pin 8 |
DIO | Digital pin 9 |
DS3231 RTC Connections
DS3231 | Arduino |
VCC | 5 V |
GND | GND |
SDA | A4 |
SCL | A5 |
Libraries for the TM1637 4-Digit Display Clock
To install the libraries, you can download them from here. Next, go to Sketch > Include Library > Add .ZIP Library… in the Arduino IDE.
TM1637 4-Digit Display Clock Source Code
By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE.
/* www.arduinopoint.com */ /* Degital 24 hour time format clock by Arduino, TM1637 4 digit 7 segment display and DS32321 RTC.*/ // Add libraries: RTClib and TM1637 #include "RTClib.h" #include <TM1637Display.h> // Define the connections pins for TM1637 4 digit 7 segment display #define CLK 8 #define DIO 9 // Create rtc and display object RTC_DS3231 rtc; TM1637Display display = TM1637Display(CLK, DIO); void setup() { // Begin serial communication at a baud rate of 9600 Serial.begin(9600); // Wait for console opening delay(3000); // Check if RTC is connected correctly if (! rtc.begin()) { Serial.println("Couldn't find RTC"); while (1); } // Check if the RTC lost power and if so, set the time: if (rtc.lostPower()) { Serial.println("RTC lost power, lets set the time!"); // The following line sets the RTC to the date & time this sketch was compiled: rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } // Set the display brightness (0-7): display.setBrightness(5); // Clear the display: display.clear(); } void loop() { // Get current date and time DateTime now = rtc.now(); // Create time format to display: int displaytime = (now.hour() * 100) + now.minute(); // Print displaytime to the Serial Monitor Serial.println(displaytime); // Display the current time in 24 hour format with leading zeros enabled and a center colon: display.showNumberDecEx(displaytime, 0b11100000, true); // Remove the following lines of code if you want a static instead of a blinking center colon: delay(1000); display.showNumberDec(displaytime, true); // Prints displaytime without center colon. delay(1000); }