TM1637 four-digit digital tube module is a 4-digit common anode digital tube (0.36 inches) display module with clock points. The driver chip is TM1637 and the driving mode is IIC. Therefore, only 2 signal lines are needed to enable the microcontroller to control the 4-digit 8-segment digital tube (the digital tube has 8 adjustable gray levels).
Control interface: 4 pins in total (GND, VCC, DIO, CLK), GND is ground, VCC is power supply, DIO is data input and output pin, CLK is clock signal pin.
TM1637.h microcontroller source program is as follows:
sbit CLK= P3^4; //define the clock line of the analog IIC bus
sbit DIO = P3^5; //define the data line of the analog IIC bus
code unsigned char tab[] =
{
0x3F,/*0*/
0x06,/*1*/
0x5B,/*2*/
0x4F,/*3*/
0x66,/*4*/
0x6D,/*5*/
0x7D,/*6*/
0x07,/*7*/
0x7F,/*8*/
0x6F,/*9*/
0x77,/*10 A*/
0x7C,/*11 b*/
0x58,/*12 c*/
0x5E,/*13 d*/
0x79,/*14 E*/
0x71,/*15 F*/
0x76,/*16 H*/
0x38,/*17 L*/
0x54,/*18 n*/
0x73,/*19 P*/
0x3E,/*20 U*/
0x00,/*21 Black screen*/
};
void Delay_us(unsigned int i)
{
for(;i>0;i--)
_nop_();;
}
//IIC starts
void TM1637_start(void)
{
CLK=1;
PART=1;
Delay_us(2);
PART=0;
}
//IIC response
void TM1637_ack(void)
{
flying i;
CLK=0;
Delay_us(5);
//PART=1;
while(DIO==1&&(i<250))i++;
CLK=1;
Delay_us(2);
CLK=0;
}
//IIC stop
void TM1637_stop(void)
{
CLK=0;
Delay_us(2);
PART=0;
Delay_us(2);
CLK=1;
Delay_us(2);
PART=1;
Delay_us(2);
}
//Write data function
void TM1637_Write(unsigned char DATA)
{
unsigned char i;
for(i=0;i<8;i++)
{
CLK=0;
if(DATA & 0x01)
PART=1;
else DIO=0;
Delay_us(3);
DATA=DATA>>1;
CLK=1;
Delay_us(3);
}
//TM1637_ack();
}
// Display in order
void TM1637_display(fly a,fly b,fly c,fly d,fly h)
{
TM1637_start();
TM1637_Write(0x40); //Write data + automatic address plus 1 + normal mode
TM1637_ack();
TM1637_stop();
TM1637_start();
TM1637_Write(0xc0); //Set the display first address, i.e. the first LED
TM1637_ack();
TM1637_Write(tab[a]);
TM1637_ack();
TM1637_Write(tab[b]|h<<7); //When h is 1, the two points in the middle of the clock are displayed
TM1637_ack();
TM1637_Write(tab[c]);
TM1637_ack();
TM1637_Write(tab[d]);
TM1637_ack();
TM1637_stop();
TM1637_start();
TM1637_Write(0x89); //Turn on display, 2/16 brightness
TM1637_ack();
TM1637_stop();
}
Previous article:51 single chip microcomputer controls the forward and reverse rotation of the motor
Next article:DS12887+lcd1602 perpetual calendar simulation schematic + program
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Help with AD9 package design
- 1. Unboxing and Review
- Brief analysis of the functional block diagram of the MSP430 series microcontroller
- NXP PLC2366 Timer 2 Interrupt Program
- Use of Linux semaphores - code testing
- Free evaluation | Ateli AT-START-F403A helps you explore and discover ARM Cortex-M4F with FPU core
- How to configure the input and output of a GPIO in the TMS320C6000 series DSP?
- Working conditions and working characteristics of switching power supply
- Let’s discuss some common misunderstandings about GaN.
- RISC-V MCU Development (IV): Compilation Configuration