新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 基于單片機的電子萬年歷

基于單片機的電子萬年歷

作者: 時間:2016-11-30 來源:網(wǎng)絡(luò) 收藏


}
void write_sfm(uchar add,uchar date)
{
uchar shi,ge;
shi=date/10;
ge=date%10;
write_com(0x80+0x40+add);
write_data(0x30+shi);
write_data(0x30+ge);;
}
void keyscan()
{
rd=0;
if(s1==0)
{
delay(5);
if(s1==0)
{
s1num++;
while(!s1);
if(s1num==1)
{ TR0=0;
write_com(0x80+0x40+10);
write_com(0x0f);
}
}


if(s1num==2)
{
write_com(0x80+0x40+7);
}
if(s1num==3)
{
write_com(0x80+0x40+4);
}
if(s1num==4)
{
s1num=0;
write_com(0x0c);
TR0=1;
}

}
if(s1num!=0)
{
if(s2==0)
{
delay(5);
if(s2==0)
{
while(!s2);
if(s1num==1)
{
miao++;
if(miao==60)
miao=0;

write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen++;
if(fen==60)
fen=0;

write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi++;
if(shi==24)
shi=0;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}

}
}
if(s3==0)
{
delay(5);
if(s3==0)
{
while(!s3);
if(s1num==1)
{
miao--;
if(miao==-1)
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen--;
if(fen==-1)
fen=59;
write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi--;
if(shi==-1)
shi=23;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}

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


}
}
}
}
void main()
{
init();
while(1)
{
keyscan();

}
}
void timer0() interrupt 1
{
TH0=0x4c;
TL0=0X00;
count++;
if(count==18)
{
count=0;
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==60)
{
fen=0;
shi++;
if(shi==24)
{
shi=0;
}
write_sfm(4,shi);
}
write_sfm(7,fen);
}
write_sfm(10,miao);
}

}


上一頁 1 2 3 下一頁

關(guān)鍵詞: 單片機電子萬年

評論


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

關(guān)閉