資源簡介
基于單片機的簡易數(shù)字時鐘仿真,課程設計結果。
(1)時間可調(diào)整。
(2)有鬧鐘功能。
(3)利用數(shù)碼管或者液晶顯示器顯示時間(XX-XX-XX 由左向右分別為:時、分、秒,且每秒更新一次)。
(4)整點報時

代碼片段和文件信息
#include?
#include?“8.h“
SYSTEMTIME?time1;
SYSTEMTIME?clocktime;
void?displaytime()
{
DS1302_GetTime(&time1);
if(Change12_24)
time1.Hour?%=?12;
TimeToStr(&time1);
GotoXY(71);
Print(time1.TimeString);
}
void?clock()
{
GotoXY(00);
Print(“clock:?“);
TimeToStr(&clocktime);
GotoXY(70);
Print(clocktime.TimeString);
while((key1?==?1)?||?(key2?==?1)) //按鍵key1或key2默認為高電平,此句進入循環(huán)?
{?
if(key1?==?0) //key1鍵調(diào)時間
{
Delay1ms(100);
if(key1?==?0)
{
if(option?==?0)
{
clocktime.Hour++;
if(Change12_24)
clocktime.Hour?%=?12;
else
clocktime.Hour?%=?24;
}
else?if(option?==?1)
{
clocktime.Minute++;
clocktime.Minute?%=?60;
}
else
{?
clocktime.Second++;
clocktime.Second?%=?60;
}
TimeToStr(&clocktime);
GotoXY(70);
Print(clocktime.TimeString);
}
}
if(key2?==?0) //key2鍵選擇時分秒
{
Delay1ms(100);
if(key2?==?0)
{
option?++;
option?%=?3;
}
}
if(key0?==?0) //key0退出
{
Delay1ms(100);
if(key0?==?0)
break;
}
displaytime();
}
}
void?time_set()
{
GotoXY(00);
Print(“chang:?“);
DS1302_GetTime(&time1);
if(Change12_24)
time1.Hour?%=?12;
TimeToStr(&time1);
GotoXY(70);
Print(time1.TimeString);
while((key1?==?1)?||?(key2?==?1)) ?
{
if(key1?==?0) //key1調(diào)節(jié)時間
{
Delay1ms(100);
if(key1?==?0)
{
if(option?==?0)
{
time1.Hour++;
if(Change12_24)
time1.Hour?%=?12;
else
time1.Hour?%=?24;
}
else?if(option?==?1)
{
time1.Minute++;
time1.Minute?%=?60;
}
else
{?
time1.Second++;
time1.Second?%=?60;
}
DS1302_SetTime(ds_hour?time1.Hour);
DS1302_SetTime(ds_minute?time1.Minute);
DS1302_SetTime(ds_second?time1.Second);
DS1302_GetTime(&time1);
if(Change12_24)
time1.Hour?%=?12;
TimeToStr(&time1);
GotoXY(70);
Print(time1.TimeString);
}
}
if(key2?==?0) ??//key2選擇時分秒
{
Delay1ms(100);
if(key2?==?0)
{
option?++;
option?%=?3;
}
}
if(key0?==?0) ?//key0退出
{
Delay1ms(100);
if(key0?==?0)
break;
}
?? displaytime();
}
}
void?sec_watch()
{
char?secondwatch[9];
unsigned?int?count?=?0;
secondwatch[8]?=?‘\0‘;
GotoXY(00);
Print(“watch:?00:00:00“);
while((key1?==?1)?||?(key2?==?1)) ?
{??
if(key1?==?0) //key1開始計時
{
Delay1ms(100);
if(key1?==?0)
{
while(key2?==?1)? //key2停止計時
{
??? Delay1ms(10);
count++;
secondwatch[0]?=?count/3600/10?+?‘0‘;
secondwatch[1]?=?count/3600%10?+?‘0‘;
secondwatch[2]?=?‘:‘;
secondwatch[3]?=?(count/60%60)/10?+?‘0‘;
secondwatch[4]?=?(count/60%60)%10?+?‘0‘;
secondwatch[5]?=?‘:‘;
secondwatch[6]?=?count%60/10?+?‘0‘;
secondwatch[7]?=
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-12-30?15:59??數(shù)字時鐘\
?????目錄???????????0??2016-12-30?16:40??數(shù)字時鐘\數(shù)字時鐘4\
?????文件???????13796??2010-12-28?20:59??數(shù)字時鐘\數(shù)字時鐘4\1228.LST
?????文件????????9732??2010-12-28?20:59??數(shù)字時鐘\數(shù)字時鐘4\1228.OBJ
?????文件???????26571??2010-12-29?08:26??數(shù)字時鐘\數(shù)字時鐘4\4
?????文件????????6701??2010-12-29?08:26??數(shù)字時鐘\數(shù)字時鐘4\4.hex
?????文件??????????35??2010-12-29?08:26??數(shù)字時鐘\數(shù)字時鐘4\4.lnp
?????文件???????32758??2010-12-29?08:26??數(shù)字時鐘\數(shù)字時鐘4\4.M51
?????文件????????1344??2010-12-29?08:30??數(shù)字時鐘\數(shù)字時鐘4\4.Opt
?????文件????????9879??2010-12-29?08:30??數(shù)字時鐘\數(shù)字時鐘4\4.plg
?????文件????????2141??2010-12-29?08:28??數(shù)字時鐘\數(shù)字時鐘4\4.Uv2
?????文件????????1345??2010-12-29?08:28??數(shù)字時鐘\數(shù)字時鐘4\4_Opt.Bak
?????文件????????2143??2010-12-28?21:01??數(shù)字時鐘\數(shù)字時鐘4\4_Uv2.Bak
?????文件????????5588??2010-12-29?08:26??數(shù)字時鐘\數(shù)字時鐘4\8.c
?????文件????????6027??2010-12-29?08:01??數(shù)字時鐘\數(shù)字時鐘4\8.h
?????文件???????18316??2010-12-29?08:26??數(shù)字時鐘\數(shù)字時鐘4\8.LST
?????文件???????30402??2010-12-29?08:26??數(shù)字時鐘\數(shù)字時鐘4\8.OBJ
?????文件????????6376??2005-03-22?15:22??數(shù)字時鐘\數(shù)字時鐘4\STARTUP.A51
?????文件???????14048??2010-12-28?20:30??數(shù)字時鐘\數(shù)字時鐘4\STARTUP.LST
?????文件?????????749??2010-12-28?20:30??數(shù)字時鐘\數(shù)字時鐘4\STARTUP.OBJ
?????文件??????118983??2010-12-29?08:29??數(shù)字時鐘\數(shù)字時鐘4\時鐘仿真.DSN
?????文件?????????935??2016-12-30?16:40??數(shù)字時鐘\數(shù)字時鐘4\時鐘仿真.PWI
- 上一篇:客戶端對服務器端的pdf文件進行自動打印
- 下一篇:Pano2vr 全景圖皮膚
評論
共有 條評論