NI
nimaltd/tm1637
tm1637 display library for STM32
๐ก TM1637 7-Segment Display Driver for STM32
A lightweight and efficient TM1637 display driver written in C for STM32 (HAL-based).
This library provides an easy way to interface STM32 MCUs with the TM1637 7-segment LED display driver โ commonly used in digital clocks, voltmeters, and similar projects.
It supports 1โ6 digits, brightness control, and formatted string display.
โจ Features
- ๐น Supports 1 to 6 digits (configurable)
- ๐น Adjustable brightness levels (0โ8)
- ๐น Displays numbers, characters, and strings
- ๐น Supports formatted printing (
printf) - ๐น Full STM32 HAL compatibility
- ๐น Simple and portable API design
- ๐น Example and video tutorial included
โ๏ธ Installation
You can install in two ways:
1. Copy files directly
Add these files to your STM32 project:
tm1637.htm1637.ctm1637_config.h
2. STM32Cube Pack Installer (Recommended)
Available in the official pack repo:
๐ STM32-PACK
๐ CubeMX Setup
- CLK (Clock) Pin โ Configure as Output Open-Drain
- DIO (Data I/O) Pin โ Configure as Output Open-Drain
- No timer or interrupt configuration is needed
Pin Connections
| Display Segment | TM1637 Pin |
|---|---|
| A | SEG1 |
| B | SEG2 |
| C | SEG3 |
| D | SEG4 |
| E | SEG5 |
| F | SEG6 |
| G | SEG7 |
| . (Dot) | SEG8 |
๐ Quick Start
Adjust delay
To ensure latency in 'tm1637_config.h', set it to a large value and then adjust it for faster response.
TM1637_DELAY 10Define and Initialize a Display
#include "tm1637.h"
tm1637_t seg =
{
.seg_cnt = 4, // Number of digits
.gpio_clk = GPIOA, // CLK pin port
.gpio_dat = GPIOA, // DIO pin port
.pin_clk = GPIO_PIN_1, // CLK pin number
.pin_data = GPIO_PIN_2, // DIO pin number
};
tm1637_init(&seg);
tm1637_str(&seg, "1234");๐งฐ API Overview
| Function | Description |
|---|---|
tm1637_init() |
Initializes the TM1637 display driver |
tm1637_brightness() |
Sets brightness level (0โ8) |
tm1637_seg() |
Configures number of active 7-segment digits |
tm1637_raw() |
Displays raw segment data buffer |
tm1637_str() |
Displays a string on the display |
tm1637_printf() |
Displays formatted text using printf style |
tm1637_clear() |
Clears all digits (turns off all segments) |
๐ฅ Example & Demo Video ( Previous Version )
๐ Support
If you find this project useful, please โญ the repo and consider supporting me:
๐ License
Licensed under the terms in the LICENSE.
On this page
Languages
C100.0%
Contributors
Other
Created July 5, 2021
Updated February 22, 2026