最佳答案
參考程序,可以調(diào)節(jié)時(shí)間,設(shè)置鬧鐘,音樂鬧鈴
#include
#include
/************************************************************/
#define uchar unsigned char
#define uint unsigned int
#define TIME (0X10000-50000)
#define FLAG 0XEF //鬧鐘標(biāo)志
/************************************************************/
//引腳連接圖
sbit CLK=P1^2;
sbit RST=P1^4;
sbit DAT=P1^3;
sbit RS=P1^5;
sbit RW=P1^6;
sbit E=P1^7;
sbit P32=P3^2;
sbit KEY1 = P2^7;
sbit KEY2 = P2^6;
sbit KEY3 = P2^5;
sbit KEY4 = P2^4;
sbit ACC_7=ACC^7;
/************************************************************/
//全局變量及常量定義
uchar i=20,j;
uchar DataBuf[16] = {};//日期
uchar TimeBuf[16] = {};//時(shí)間
uchar alarm[2],time[3];
uchar code Day[]={31,28,31,30,31,30,31,31,30,31,30,31};//12個(gè)月的最大日期(非閏年)
//閏年月星期表
const unsigned char WeekTab[] = {
(3 << 5) + 31,///1月
(6 << 5) + 29,///2月
(0 << 5) + 31,///3月
(3 << 5) + 30,///4月
(5 << 5) + 31,//5月
(1 << 5) + 30,//6月
(3 << 5) + 31,//7月
(6 << 5) + 31,//8月
(1 << 5) + 30,//9月
(4 << 5) + 31,//10月
(0 << 5) + 30,//11月
(2 << 5) + 31 //12月
};
//音律表
uint code table1[]={64260,64400,64524,64580,64684,64777,64820,64898,64968,65030,65058,65110,65157,65178,65217};
//發(fā)聲部分的延時(shí)時(shí)間
uchar code table2[]={0x82,1,0x81,0xf4,0xd4,0xb4,0xa4,0x94,0xe2,1,0xe1,0xd4,0xb4,0xc4,0xb4,4,0};
//鬧鐘中用的全局變量
uchar th1,tl1;
/************************************************************/
//延時(shí)1ms函數(shù)
delay1ms(uchar time)
{
uchar i,j;
for(i=0;i
回答者:chrisgz912016-04-30 00:00