仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.png (22.9 KB, 下載次數: 25)
下載附件
2021-5-19 02:55 上傳
BET630R4J~5_~30~9087PUG.png (190.93 KB, 下載次數: 71)
下載附件
仿真圖
2019-6-8 13:47 上傳
6XDE5$U}JS85DQ}9~){Y%DF.png (48.14 KB, 下載次數: 70)
下載附件
文檔
2019-6-8 13:47 上傳
單片機源程序如下:
- #include<reg52.h>
- #include<lcd.h>
- #include<1302.h>
- #include<music_code.h>
- #include<SoundPlay.h>
- #include<dds.h>
- uchar code time[]={'0','1','2','3','4','5','6','7','8','9'};
- uchar code get_up[]="Time to Get up!";
- uchar code str[]="Never frown,even when you are sad,because you never know who is falling in love with your smile! To the world you may be one person,but to one person you may be the world ";
- uchar code menu[4][10]={{"Time Set"},{"Music"},{"Books"},{"Ring Set"}};
- void main()
- {
- ini();
- open();
- delay(255);
- delay(255);
- delay(255);
- delay(255);
- write_order(0x01);
- init_ds1302();
- set_ds1302(time_add,initial_time);
- while(1)
- {
- read_ring();
- if(ring_time[0]==now_time[0]&&ring_time[1]==now_time[1]&&ring_time[2]==now_time[2])
- {
- timeup();
- }
- detect();
- write_order(0x80+0x04);
- for(i=0;menu[key][i]!=0;i++)
- {
- write_date(menu[key][i]);
- }
- get_ds1302();
- write_order(0x80+0x40);
- write_date(time[now_time[4]>>4]);
- write_date(time[now_time[4]&0x0f]);
- write_date(0x01);
- write_date(time[now_time[3]>>4]);
- write_date(time[now_time[3]&0x0f]);
- write_date(0x00);
- write_date(' ');
- write_date(' ');
- write_date(time[now_time[2]>>4]);
- write_date(time[now_time[2]&0x0f]);
- write_date(':');
- write_date(time[now_time[1]>>4]);
- write_date(time[now_time[1]&0x0f]);
- write_date(':');
- write_date(time[now_time[0]>>4]);
- write_date(time[now_time[0]&0x0f]);
- if(key==2)
- {
-
- sum=0;
- book();
- }
- if(key==1)
- {
- music();
- }
- if(key==3)
- {
- alamn();
-
- }
- if(key==0)
- {
- time_set();
-
- }
- }
- }
- void detect()
- {
- uchar temp;
- temp=P1;
- temp=temp&0x0f;
- if(temp!=0x0f)
- {
- switch(temp)
- {
- case 0x0e:
- while(temp!=0x0f)
- {
- temp=P1;
- temp=temp&0x0f;
- }
- if(key==0)
- {
- key=4;
- }
- key--;
- flag=1;
- write_order(0x01);
- break;
- case 0x0d:
- while(temp!=0x0f)
- {
- temp=P1;
- temp=temp&0x0f;
- }
- key++;
- flag=2;
- if(key==4)
- {
- key=0;
- }
- write_order(0x01);
- break;
- case 0x0b:
- while(temp!=0x0f)
- {
- temp=P1;
- temp=temp&0x0f;
- }
- flag=3;
- write_order(0x01);
- break;
- case 0x07:
- while(temp!=0x0f)
- {
- temp=P1;
- temp=temp&0x0f;
- }
- flag=4;
- write_order(0x01);
- break;
- }
- }
- }
- void page(uchar k)
- {
- write_order(0x80);
- for(i=k*32;i<k*32+16&&str[i]!='\0';i++)
- {
- write_date(str[i]);
- }
- write_order(0x80+0x40);
- for(i=k*32+16;i<k*32+32&&str[i]!='\0';i++)
- {
- write_date(str[i]);
- }
- }
- void book()
- {
-
- flag=0;
- detect();
- if(flag==3)
- {
- flag=0;
- page(sum);
- while(flag!=4)
- {
- detect();
- if(flag==1)
- {
- flag=0;
- if(sum!=0)
- {
- sum--;
- }
- page(sum);
- }
- if(flag==2)
- {
- flag=0;
- if(sum<5)
- {
- sum++;
- }
- page(sum);
- }
- }
- key=2;
- }
- }
- void alamn()
- {
- flag=0;
- detect();
- if(flag==3)
- {
- flag=0;
- while(flag!=4)
- {
- write_order(0x80+0x02);
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
多功能音樂播放器仿真程序.7z
(46.71 KB, 下載次數: 157)
2021-5-19 02:59 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
網上找的文檔資料.7z
(441.5 KB, 下載次數: 5)
2021-5-19 02:58 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|