基于单片机数码管电子闹钟仿真设计
1478下载地址 https://docs.qq.com/doc/DWEpnR2pOWU91b3p4?pub=1&dver=2.1.0
#include <regx51.h> #include <intrins.h> sfr AUXR = 0x8e; /*数码管显示字符转换表*/ unsigned char tab[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40,0x39}; signed char num[] = {10,10,10,10,10,10,10,10}; //数码管显示缓冲区 signed char timeclock[] = {0,0,11,0,0,11,0,0}; //闹钟时间 unsigned char TRH0,TRL0; //T0重载值的高字节和低字节 bit clock = 0; //闹钟时间到标志位 bit flag = 0; //1s闪烁标志位 bit flag200ms = 0; //200ms定时标志位 bit timesetup = 0; //时间设置标志位 bit clocksetup = 0; //闹钟设置标志位 unsigned position = 0; //设置小时,分钟,秒标志位(‘1’小时,‘2’分钟,‘3’秒) unsigned char Temp; //温度值 unsigned char Time[5]; //时间值 void key(); //按键判断执行函数 void Ds1302_Display(); //时间显示函数 void Ds18b20_Display(); //温度显示函数 extern void Ds1302_Init(); //DS1302初始化函数 void Ds1302_Time(unsigned char *time); //带参数的向DS18B20写时间 extern void Write_Ds1302_Byte(unsigned char temp); //向DS1302写入数据 extern unsigned char Read_Ds1302 (unsigned char address); //从DS1302读取数据 extern unsigned char DS18B20_Temp(); //读取DS18B20温度值