基于51单片机控制的语音报时万年历课程设计Word文档格式.docx

上传人:b****3 文档编号:13556401 上传时间:2022-10-11 格式:DOCX 页数:50 大小:154.41KB
下载 相关 举报
基于51单片机控制的语音报时万年历课程设计Word文档格式.docx_第1页
第1页 / 共50页
基于51单片机控制的语音报时万年历课程设计Word文档格式.docx_第2页
第2页 / 共50页
基于51单片机控制的语音报时万年历课程设计Word文档格式.docx_第3页
第3页 / 共50页
基于51单片机控制的语音报时万年历课程设计Word文档格式.docx_第4页
第4页 / 共50页
基于51单片机控制的语音报时万年历课程设计Word文档格式.docx_第5页
第5页 / 共50页
点击查看更多>>
下载资源
资源描述

基于51单片机控制的语音报时万年历课程设计Word文档格式.docx

《基于51单片机控制的语音报时万年历课程设计Word文档格式.docx》由会员分享,可在线阅读,更多相关《基于51单片机控制的语音报时万年历课程设计Word文档格式.docx(50页珍藏版)》请在冰豆网上搜索。

基于51单片机控制的语音报时万年历课程设计Word文档格式.docx

3.电路硬件设计

实际效果图

4.程序代码部分

Main.h

#ifndef_MAIN_H

#define_MAIN_H

#include"

reg52.h"

INTRINS.H"

math.h"

string.h"

key.h"

led.h"

12864.h"

main.h"

isd1700.h"

sound.h"

externunsignedintcount;

externunsignedintkey_time[8];

externunsignedcharkey_new;

externunsignedcharkey_old;

externunsignedcharstop_flag;

externunsignedcharkey_follow[8];

externunsignedintkey_num[8];

sbitBEEP=P3^7;

sbitISD_SS=P0^7;

sbitISD_MISO=P0^4;

sbitISD_MOSI=P0^5;

sbitISD_SCLK=P0^6;

externunsignedchardate_show[];

externunsignedchartime_show[];

externunsignedcharsec;

externunsignedcharmin;

externunsignedcharhour;

externunsignedcharday;

externunsignedcharmonth;

externunsignedcharyear_f;

externunsignedcharyear_l;

externunsignedcharleap_year_flag;

externunsignedcharupdate_flag;

externunsignedcharadjust_flag;

externunsignedcharkey;

unsignedcharreport();

#endif

Main.c

unsignedintcount=0;

unsignedintkey_num[8]=0;

unsignedcharkey_new=0;

unsignedcharkey_old=0;

unsignedcharstop_flag=0;

unsignedcharkey_follow[8]=0;

unsignedcharsec=1;

unsignedcharmin=0;

unsignedcharhour=9;

unsignedcharday=1;

unsignedcharmonth=1;

unsignedcharyear_f=20;

unsignedcharyear_l=14;

unsignedcharleap_year_flag=0;

unsignedchardate_show[]="

2014-01-01"

;

unsignedchartime_show[]="

09:

00"

unsignedcharupdate_flag=1;

unsignedcharkey=0;

unsignedcharadjust_flag=0;

unsignedcharadjust_pos=0;

unsignedcharreport_flag=0;

voidmain()

{

unsignedchari;

P2=0XFF;

BEEP=0;

init();

initinal();

//调用LCD字库初始化程序

TMOD=0x01;

//使用定时器T0

TH0=(65536-1000)/256;

//定时器高八位赋初值

TL0=(65536-1000)%256;

//定时器低八位赋初值*/

EA=1;

//开中断总允许

ET0=1;

//允许T0中断

TR0=1;

//启动定时器T0

while

(1)

{

if(update_flag)

{

lcd_pos(1,0);

for(i=0;

i<

10;

i++)

write_dat(date_show[i]);

lcd_pos(2,4);

8;

write_dat(time_show[i]);

update_flag=0;

}

if(key!

=keyscan_nor())

key=keyscan_nor();

if(key==8&

&

!

adjust_flag)

adjust_flag=1;

if(key&

adjust_flag)

if(key==1)

{

adjust_pos++;

if(adjust_pos==14)

adjust_pos=0;

}

elseif(key==2)

if(!

adjust_pos)

adjust_pos=13;

else

adjust_pos--;

elseif(key==6)

sec++;

elseif(adjust_pos==1)

sec=sec+10;

elseif(adjust_pos==2)

min++;

elseif(adjust_pos==3)

min=min+10;

elseif(adjust_pos==4)

hour++;

elseif(adjust_pos==5)

hour=hour+10;

elseif(adjust_pos==6)

day++;

elseif(adjust_pos==7)

day=day+10;

elseif(adjust_pos==8)

month++;

elseif(adjust_pos==9)

month=month+10;

elseif(adjust_pos==10)

year_l++;

elseif(adjust_pos==11)

year_l=year_l+10;

elseif(adjust_pos==12)

year_f++;

elseif(adjust_pos==13)

year_f=year_f+10;

elseif(key==7)

sec--;

sec=sec-10;

min--;

min=min-10;

hour--;

hour=hour-10;

day--;

day=day-10;

month--;

month=month-10;

year_l--;

year_l=year_l-10;

year_f--;

year_f=year_f-10;

elseif(key==3)

adjust_flag=0;

if(key==6||key==7)

if(sec>

=80)

sec=0;

if(min>

min=0;

if(hour>

=40)

hour=0;

if(month>

30)

month=1;

if(day>

50)

day=0;

if(year_f>

=120)

year_f=0;

if(year_l>

year_l=0;

}

if(key==3)

report_flag=1;

if(report_flag)

clrram();

Dingwei(2,1);

lcd_mesg("

REPORTING!

"

);

report();

}

voidtime0()interrupt1

staticunsignedchartimer=0;

TH0=(65536-50000)/256;

TL0=(65536-50000)%256;

//定时器低八位赋初值

timer++;

if(timer==2

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1