用stm8写的TM1638程序.txt



#include
#include

unsigned char num[8]; //各个数码管显示的值

void init(void)
{
PC_DDR_DDR5=1;
PC_CR1_C15=1;
PC_CR2_C25=0;
PC_DDR_DDR6=1;
PC_CR1_C16=1;
PC_CR2_C26=0;
PC_DDR_DDR7=1;
PC_CR1_C17=1;
PC_CR2_C27=0;
}

unsigned char tab[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,
0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};

int main(void)
{
init();
unsigned char j;
unsigned char i;
Write_COM(0x8a);//亮度
Write_COM(0x40); //写 数据命令
STB=0;
TM1638_Write(0xc0); //写地址命令
for(i=0;i<16;i++)
TM1638_Write(0x00);
Write_COM(0x44);
STB=0;
TM1638_Write(0xc8);
TM1638_Write(0xff);

STB=1;

while(1){
j=Read_key();
j=tab[j];

STB=0;
TM1638_Write(0xc0); //写地址命
TM1638_Write(j);
STB=1;
delay_ms(1000);

}






}


相关主题
相关文档
最新文档