云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 51单片机+ds1302+DS18b20温度时钟(电路图+C语言程序)

51单片机+ds1302+DS18b20温度时钟(电路图+C语言程序)

  • 62 次阅读
  • 3 次下载
  • 2025/5/4 16:07:51

clock_en=0;//开机时默认关闭闹钟 init_t0(); TR0=1;//

// set_ds1302();//设置DS1302的初始时间 //接下来开始编写让数码管显示的程序 while(1) {

get_ds1302();

judge_dis();//显示处理 judge_s1(); judge_s2(); judge_s3();

judge_clock();//闹钟处理程序 } }

void timer0() interrupt 1 {

TH0=(65536-50000)/256; TL0=(65536-50000)%6; t0_crycle++;

if(t0_crycle==2)// 0.1秒 {

t0_crycle=0;

msecond_flag=1; msecond_count++;

if(msecond_count==10)//1秒 {

msecond_count=0; second_flag=1; } } }

//************************************************** //显示处理函数 void judge_dis() {

if(flag1==0) {

if(second_flag==1) {

zancun7++; second_flag=0; }

if(zancun7<1)

{

if(temp_flag2==1) {

readtemp_ds18b20();//读取温度 temp_flag2=0; }

dis_temp();//温度显示函数 }

if(zancun7>=1) {

temp_flag2=1;

zancun4=hour_count&0xf0; zancun4>>=4;

zancun5=minute_count&0xf0; zancun5>>=4;

zancun6=second_count&0xf0; zancun6>>=4;

dis(zancun4,hour_count&0x0f,zancun5,minute_count&0x0f,zancun6,second_count&0x0f);

dis_led();

if(zancun7==5)zancun7=0; } }

if(flag1!=0) {

switch(flag1) {

case 1:

dis(5,10,11,1,12,12);//显示SET1 led1_bit=1; led2_bit=1; break; case 2:

dis(5,10,11,2,12,12);//显示SET2 break; case 3:

dis(5,10,11,3,12,12);//显示SET3 break; case 4:

dis(5,10,11,4,12,12);//显示SET4 break; case 5:

dis(5,10,11,5,12,12);//显示SET5 break; case 6:

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,12,12,1); break; case 7:

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,12,12,2); break; case 8:

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,12,12,3); break;

case 9://进入修改时间,时间分位个位闪烁

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,12,12,4); break;

case 10://进入修改闹钟,闹钟小时十位闪烁

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,12,zancun3,1); break;

case 11://进入修改闹钟,闹钟小时个位闪烁

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,12,zancun3,2); break;

case 12://进入修改闹钟,闹钟小时十位闪烁

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,12,zancun3,3); break;

case 13://进入修改闹钟,闹钟小时个位闪烁

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,12,zancun3,4); break;

case 14://进入修改闹钟的开关

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,12,zancun3,6); break; case 15:

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,zancun3/10,zancun3,1);

break; case 16:

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,zancun3/10,zancun3,2);

break; case 17:

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,zancun3/10,zancun3,3);

break; case 18:

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,zancun3/10,zancun3,4);

break; case 19:

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,zancun3/10,zancun3,5);

break; case 20:

dis_san(zancun1/10,zancun1,zancun2/10,zancun2,zancun3/10,zancun3,6);

break; case 21:

if(second_flag==1) {

second_flag=0;

countdown_second--;

if(countdown_second==255) {

countdown_second=59; countdown_minute--;

if(countdown_minute==255) {

countdown_minute=59; countdown_hour--;

if(countdown_hour==255) {

flag1=22;

countdown_minute=0; countdown_hour=0; countdown_second=0; countdown_flag=1;

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

clock_en=0;//开机时默认关闭闹钟 init_t0(); TR0=1;// // set_ds1302();//设置DS1302的初始时间 //接下来开始编写让数码管显示的程序 while(1) { get_ds1302(); judge_dis();//显示处理 judge_s1(); judge_s2(); judge_s3(); judge_clock();//闹钟处理程序 } } void timer0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%6; t0_crycle++;

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com