// file name:shu ma guan.c
// designer: PES_LiWeiJin
#include”reg51.h”
#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…
}
}
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/yingyong/260242.html