This project demonstrates how to interface a TM1637 4-digit 7-segment display with an STM32F103C6 microcontroller using GPIO bit-banging.
The TM1637 allows easy numeric display output with programmable brightness control. By using STM32 GPIOs for communication, this setup provides a lightweight solution without requiring dedicated hardware interfaces. The project includes full Proteus simulation support for validation and testing.
STM32CubeMX Setup- MCU Selection: STM32F103C6 (8 MHz clock)
- GPIO Configuration:
-
PA0 → CLK (Output Push-Pull)
-
PA1 → DIO (Output Push-Pull)
- Generate initialization code and open the project in STM32CubeIDE.
Key Functions
- Display Initialization
-void TM1637_Init(void);
-Configures CLK/DIO timing.
- Display Decimal Value
-void TM1637_DisplayDecimal(int value, bool showColon);
- Set Brightness
-void TM1637_SetBrightness(uint8_t level);
- Main Loop exemple
TM1637_Init();
TM1637_SetBrightness(7);
while (1)
{
TM1637_DisplayDecimal(1234, true);
HAL_Delay(1000);
}
Required Components:
- STM32F103C6 microcontroller
- TM1637 4-digit display
- Pull-up resistors (10 kΩ on CLK and DIO)
Connections:
- PA0 → CLK pin of TM1637
- PA1 → DIO pin of TM1637
- VCC → 5V
- GND → GND
Steps:
- Load the.hex file generated from STM32CubeIDE.
- Run the simulation.
- Observe numeric output and brightness control on the TM1637 display.
If you have any questions or suggestions don't hesitate to leave a comment below
Comments