The schematic diagram is as follows,
and part of the program is as follows.
The microcontroller source program is as follows:
#include #include "DS18B20.h" #include "DS1302.h" #include "LCD12864.h" char a; sbit KEY1=P3^4; sbit KEY2=P3^5; sbit KEY3=P3^6; bit flag=1; //Enter/Exit setting flag uchar choose=0x01; //Switch flag void delay10(void) //delay 10ms { unsigned char i,j; for(i=0;i<255;i++) for(j=0;j<200;j++); } void delay5ms(void) //error 0us { unsigned char a,b; for(b=19;b>0;b--) for(a=130;a>0;a--); } //When setting, the ds1302 register value cycles, such as the second register 59 plus one to 00 unsigned char conver(unsigned char a,unsigned char b,unsigned char c) { if((a&0x0f)==0x0a) a=a+6; if(a==b) a=c; return a; } void digplay() { //time ShowNumber16_32(2,0,TIME[2]>>4&0x03); //Time tens digit ShowNumber16_32(2,16, TIME[2]&0x0f); //Hour unit digit ShowNumber16_32(2,48,TIME[1]>>4&0x07);//minutes and tens ShowNumber16_32(2,64, TIME[1]&0x0f); //Minutes and units ShowNumber16_32(2,96,TIME[0]>>4&0x07);//ten digits of seconds ShowNumber16_32(2,112, TIME[0]&0x0f); //seconds units //date ShowNumber(0,0,2); ShowNumber(0,8,0); ShowNumber(0,16,TIME[6]>>4&0x0f); ShowNumber(0,24, TIME[6]&0x0f);//年 ShowNumber(0,40,TIME[4]>>4&0x01); ShowNumber(0,48, TIME[4]&0x0f);//月 ShowNumber(0,64,TIME[3]>>4&0x03); ShowNumber(0,72, TIME[3]&0x0f);//日 ShowChina(0,112,(TIME[5]&0x07)-1);//周 } void wendu() { //temperature a=Read_Temperature(); //Read the temperature of DS18B20 if(a<0) //Processing temperature positive and negative { a = (-1)*a; // complement ShowNumber(6,88,11); //Thermometer icon— } else { ShowNumber(6,88,12); //Thermometer icon + } ShowNumber(6,96,a/10%10); //Show the median temperature ShowNumber(6,104,a%10); //Display low temperature } void digplaystart() {//Power on display fly i=0; ShowChina(2,64-16*1.5,19); ShowChina(2,64-16*0.5,20); ShowChina(2,64+16*0.5,21); ShowChina(2,64+16*1.5,22); for (i=0;i<10;i++) { ShowNumber(4,32+8*i,16); delay5ms(); delay5ms(); } ClearScreen(0);//清屏 } void main(void) { flying i; InitLCD(); //Initialize LCD12864 digplaystart(); delay5ms(); Ds1302Init(); //Ds1302 initializes and sets the default time a=Read_Temperature(); //Read the temperature of DS18B20 ShowNumber(0,32,11);//- ShowNumber(0,56,11);//- ShowChina(0,96,7);//Chinese Character Week ShowNumber16_32(2,32,10);//: ShowNumber16_32(2,80,10);//: ShowChina(6,112,8);//℃ while(1) { wendu(); //Temperature display if(flag==1) Ds1302ReadTime(); //Read the time of DS1302 else Ds1302WriteTime(); if(KEY1==0) //Key 1--processing setting time and return { delay10(); if(KEY1==1) { delay10(); flag=~flag; if(flag==0) { ShowChina(6,48,9); ShowChina(6,0,16); ShowChina(6,16,17); ShowNumber(6,32,10); } if(flag==1) { for( i=0;i<8;i++) { ShowNumber(6,8*i,15); } } } } if(KEY2==0) //Key 2--process the item to select the set time { delay10(); if(KEY2==1) { delay10(); choose++; ShowChina(6,48,8+choose); if(choose==7) choose=0x00; } } if(KEY3==0) //Key 3--processing setting time and return { delay10(); if(KEY3==1) { delay10(); switch(choose) { case 1: TIME[6]++; TIME[6]=conver(TIME[6],0xa0,0x00);break;//年 case 2: TIME[5]++; TIME[5]=conver(TIME[5],0x08,0x01);break;//周 ……………………
Previous article:The ultimate program of 1602 calculator with single chip computer and clock
Next article:LD3320 routine based on 51 single chip microcomputer (password mode + IO port control program)
Recommended ReadingLatest update time:2024-11-16 15:29
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Summary of performance indicators of integrated operational amplifiers
- EEWORLD University - Using the 75 W TAS6424-Q1 Class D Audio Amplifier for DC and AC Load Diagnostics
- EEWORLD University Hall----Live playback: High-performance i.MX RT processors help smart nodes achieve machine learning without Internet access
- Help, failed to create new IP core
- Setting the switching frequency of the switching power supply chip LTM4613
- Does the power layer of a four-layer board need to be made into a complete plane?
- [Register to enjoy gifts] element16 sincerely invites you to visit the 2019 Munich Shanghai Electronics Show
- EEWORLD University Hall----Live playback: AM57X platform features and typical applications
- 【ST NUCLEO-H743ZI Review】(1) First experience lighting up the LED
- bluenrg chat example