功能描述:产品可以显示时间和日期,时间格式为 hh mm ss 日期格式为 yy.mm.dd 时间和日期轮流显示。 时间显示5S 日期显示3S。 可以设置5 个闹铃,闹铃音乐可以设置两种:毛驴和童年。 三个按键对时间和闹铃进行设置,六个LED 进行显示。 计时采用DS1307。继电时间不丢失,设置过的闹铃也不丢失。 闹铃音乐由单片机的两个定时器去产生频率实现。 部分程序如下: //************************************************* //************************************************ //*********************************************** //程序名:DS1307 时钟程序 //功能描述:用六个八段LED 轮流显示时间 // 和日期。有6 个闹钟。上电时从DS1307 中读出 // 当前时间、日期、闹钟。 // // // // // #include #include #define uchar unsigned char #define uint unsigned int #define LED P2 #define LEDBit P0 #define nop _nop_() #define LightCount 40 #define LightMax 80 sbit SCL=P3^1; sbit SDA=P3^0; sbit ModeKey=P1^0; sbit UpKey=P1^1; sbit DownKey=P1^2; sbit Speak=P3^6; code uchar LCD_NUM[10]={0x03,0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x09}; //0x25, //uchar Clock[]={0x88,0x88,0x88}; code uint Music_Sound_Long1[]={4,8,4,8,8,4,8,4,4,4, /*童年*/ 8,4,8,4,4,4,4,4,16,4, 4,8,4,4,4,4,4,8,4,4, 4,8,4,4,4,4,4,4,16,4, 4,8,4,4,4,4,4,8,4,4, 4,8,4,4,4,4,4,4,16,4, 8,4,8,4,4,4,8,8,4,4, 4,4,4,4,4,4,4,4,4,16, 4,8,4,8,8,4,8,4,4,4, 8,4,8,4,4,4,4,4,16,4, 8,4,8,8,4,8,4,4,4,8, 4,8,4,4,4,4,4,16,0}, Music_Sound_Long2[]={4,4,4,4,4,4,4,4,4,4, /*小毛驴*/ 4,4,16,4,4,4,4,4,4,4, 4,4,4,4,4,8,4,4,4,4, 4,4,4,4,4,4,4,4,4,16, 4,4,4,4,2,2,2,2,4,4, 4,4,4,4,16,0}, Music_Sound_Tone1[]={379,379,379,379,425,477,477,477,425,477, 568,637,637,637,568,637,425,379,477,719, 637,637,719,637,568,568,506,568,568,568, 637,477,477,477,477,568,477,568,637,719, 637,637,719,637,568,568,506,568,568,568, 637,477,477,477,477,568,568,477,851,318, 318,318,318,379,425,477,477,568,477,568, 477,425,425,425,425,425,477,379,425,425, 379,379,379,379,425,477,477,477,425,477...