51單片機(jī)驅(qū)動(dòng)16*16點(diǎn)陣顯示生日快樂程序
Delayms(uint c)
{
uint a,b;
for(a=0;a
}
void write(uchar com,uchar da)
{
uchar temp,i,j;
load=0;
clk=0;
for(i=0;i<8;i++)
{ temp=com;
if((temp&(0x80>>i))!=0)
din=1;
else din=0;
clk=1;
for(j=0;j<5;j++);
clk=0;
}
for(i=0;i<8;i++)
{ temp=da;
if((temp&(0x80>>i))!=0)
din=1;
else din=0;
clk=1;
for(j=0;j<5;j++);
clk=0;
}
load=1;本文引用地址:http://butianyuan.cn/article/201611/323745.htm
}
void main()
{
csh();
write(0x0c,0x01);//正常工作狀態(tài),關(guān)斷模式
write(0x09,0x00);//譯碼選擇,非BCD碼
write(0x0a,0x0a);//亮度調(diào)節(jié)
write(0x0b,0x07);//顯示位數(shù)
Initial_DS1302();
while(1)
{
DS1302_GetTime(&time1);
buf[7]=(time1.Second)%10;
buf[6]=(time1.Second)/10;
buf[4]=(time1.Minute)%10;
buf[3]=(time1.Minute)/10;
buf[1]=(time1.Hour)%10;
buf[0]=(time1.Hour)/10;
write(0x08,dispcode[buf[7]]);
write(0x07,dispcode[buf[6]]);
write(0x06,dispcode[10]);
write(0x05,dispcode[buf[4]]);
write(0x04,dispcode[buf[3]]);
write(0x03,dispcode[10]);
write(0x02,dispcode[buf[1]]);
write(0x01,dispcode[buf[0]]);
// Delayms(200);
num++;
if(num==137)
num=0;
for(r=0;r<105;r++)
for(j=q;j<32+q;j++)
{
P1=tab2[t];
KAI=1;
P2=0X00;
P2=tab1[j];
KAI=0;
j++;
KAI2=1;
P2=0X00;
P2=tab1[j];
KAI2=0;
P0=tab3[num];
delay(40);
t++;
if(t==16)
t=0;
}
q=q+32;
if(q==256)
q=0;
}
}
void delay(uint time)
{
uint linger;
for(linger=0;linger}
評論