可调时报时的单片机电子钟
5页1、可调时报时的单片机电子钟可调时报时的单片机电子钟#include #define uchar unsigned char#define uint unsigned int#define ulong unsigned longsbit p3_0=P30; /显示日期显示日期sbit p3_1=P31; /时间设置外部中断时间设置外部中断 0sbit p3_2=P32; /选择设置位选择设置位sbit p3_3=P33; /时间设置时间设置+1sbit p3_4=P34; /设置完成,电子钟开始走设置完成,电子钟开始走sbit p3_5=P00; /闹铃显示闹铃显示bit flag=0; /判断一般显示还是设置显示位判断一般显示还是设置显示位uint g_month=31,28,31,30,31,30,31,31,30,31,30,31; /非闰年非闰年uint r_month=31,29,31,30,31,30,31,31,30,31,30,31 ; /闰年闰年uint times=59; /T0 一秒中断次数一秒中断次数uint settimes=1; /设置位初始为最高位设置位初始为
2、最高位年年uchar whichshow=0x80; /显示位初始为最高位显示位初始为最高位uchar yu; /显示设置的位显示设置的位uint stor; /存放设置开始时显示的位存放设置开始时显示的位struct date uint year; uint month;uint day;date1=00,1,1; /初始化日期初始化日期struct timeuint hour;uint minite;uint second;time1=0,0,0; /初始化时间初始化时间struct time time2=0,0,0;union showdata /定义显示的位为共用体定义显示的位为共用体uint year1,year2;uint month1,month2;uint day1,day2;a; union showtimeuint hour1,hour2;uint min1,min2;uint sec1,sec2;b;void delay(uint i) /延时程序延时程序 ims uchar j;while(i-)for(j=0;j1;whichshow=x|y;void dis
3、play() /时间显示程序时间显示程序if(p3_0=1) /显示时分秒显示时分秒b.hour1=time1.hour/10; show(b.hour1); /时高位时高位 02b.hour2=time1.hour%10; show(b.hour2); /时低位时低位 09show(10);/横线横线 b.min1=time1.minite/10; show(b.min1); /分高位分高位 05b.min2=time1.minite%10; show(b.min2); /分低位分低位 09show(10);/横线横线b.sec1=time1.second/10; show(b.sec1); /秒高位秒高位 05b.sec2=time1.second%10; show(b.sec2); /秒低位秒低位 09if(p3_0=0) /显示年月日显示年月日a.year1=date1.year/10;show(a.year1); /年年a.year2=date1.year%10;show(a.year2);show(10);/横线横线a.month1=date1.month/10;show(
《可调时报时的单片机电子钟》由会员ldj****22分享,可在线阅读,更多相关《可调时报时的单片机电子钟》请在金锄头文库上搜索。
2024-04-24 8页
2024-04-24 1页
2024-04-24 1页
2024-04-24 1页
2024-04-24 3页
2024-04-24 8页
2024-04-24 5页
2024-04-23 12页
2024-04-23 5页
2024-04-23 4页