Overview
TM1637 is a LED controller circuit with keyboard scan function. We can use it to drive LED, multiplexing display, and keypad input scanning. Its LED control output duty can be adjust by software. This chip is popular for Arduino users. It comes with a 7-segment display module, and keypad.
Proteus Simulation |
Its communication interface is similar to Inter Integrated Circuit (I2C). But the LSB of data is sent first. This chip doesn't have slave address that the I2C does. What the controller send is command and data.
TM1637 Features |
TM1637 Pin Functions |
Keypad scanning start at the end of display. It's a 6x2 keypad matrix.
Keypad Interface |
Display Data Register has up to six addresses.
Display Register Address |
TM1637 Data Command |
Address Command Setting |
Address Command Setting |
Display Control Command |
The display ON command is 0x88. We must add pulse width value (ranges 0 to 7) to adjust display brightness for example 0x88+3.
TM1637 SRAM data writing mode |
The controller may write data or command to this chip using auto increment 1, fixed address mode.
PIC16F887 MPLABX XC8 Programming
MPLABX IDE and XC8 C compiler is free to use. In this example, PIC16F887 send 7-Segment data to a six-digit display.
/* * File: main.c * Author: Admin * * Created on January 12, 2024, 3:08 PM */ #include <xc.h> #include "config.h" #include "tm1637.h" #define _XTAL_FREQ 8000000UL const char msg_1[]={0x76,0x79,0x38,0x38,0x3F}; void main(void) { char txt[7],count=0; OSCCONbits.IRCF=7; TM1637Init(); for(uint8_t i=0;i<5;i++) display(i,msg_1[i]); __delay_ms(3000); clearDisplay(); while(1){ txt[6]=data_7[count]; for(uint8_t i=0;i<6;i++) txt[i]=txt[i+1]; /* txt[6]=data_7[count]; txt[0]=txt[1]; txt[1]=txt[2]; txt[2]=txt[3]; txt[3]=txt[4]; txt[4]=txt[5]; txt[5]=txt[6]; */ for(uint8_t i=0;i<6;i++) display(i,txt[i]); count++; __delay_ms(1000); if(count==16) count=0; } return; }
I don't have a TM1637 nor an TM1637 display module. So I use Proteus VSM to simulate this program.
Click here to download its source file.
No comments:
Post a Comment