新聞中心

MCU SOURCE FILE_數(shù)碼管

作者: 時(shí)間:2016-11-24 來(lái)源:網(wǎng)絡(luò) 收藏

// file name:shu ma guan.c
// designer: PES_LiWeiJin

#include"reg51.h"

本文引用地址:http://m.butianyuan.cn/article/201611/320825.htm

#define uchar unsigned char
#define uint unsigned int

uchar leddata[]={
0xC0,0xF9, 0xA4, 0xB0, 0x99, 0x92,
0x82, 0xF8, 0x80, 0x90,0x88
};
uchar ddshow[]={0x00,0x00,0x00,0x00};

uchar scan[]={0xfe,0xfd,0xfb,0xf7};
//delay for 1ms
void delay1ms(uint t)
{
uint i;
uchar j;
for(i=0;i for(j=0;j<120;j++);
}

//show leddata
void datashow()
{
ddshow[0]++;
delay1ms(100); //try to change the delay value...
if(ddshow[0]==10)
{
ddshow[0]=0;
ddshow[1]++;
if(ddshow[1]==6)
{
ddshow[1]=0;
ddshow[2]++;
if(ddshow[2]==10)
{
ddshow[2]=0;
ddshow[3]++;
if(ddshow[3]==6)
ddshow[3]=0;
ddshow[2]=0;
ddshow[1]=0;
ddshow[0]=0;
}
}

}
}
//main
void main()
{
uchar i;
while(1)
{
datashow();
for(i=0;i<4;i++)
{
P0=leddata[ddshow[i]];
P1=scan[i];
delay1ms(1); //try to change the delay value...
}
}

}



關(guān)鍵詞: MCUSOURCEFILE數(shù)碼

評(píng)論


技術(shù)專區(qū)

關(guān)閉