The microcontroller source program is as follows:
#include #include"MLX906.h" #include"LCD1602.h" #include"EEPROM.h" #include"I2C.h" #include"WT558D.h" #include"USART.h" sbit red =P3^3; sbit green =P3^4; sbit blue =P3^5; sbit key = P3^6; uchar tab[] ="Temp:"; int main() { flying i; uint wendu; //Store the read value uint xiaoshu,zhengshu; //Store decimals and integers uchar ge,shi,bai,fyi,fer; //Store the first digit of the unit, ten, hundred, fraction, and the second digit of the fraction double num; UsartInit(); Lcd_init(); for(i=0;i<5;i++) { write_data(tab[i]); } bai = EEPROM_read_data(0); shi = EEPROM_read_data(1); ge = EEPROM_read_data(2); fyi = EEPROM_read_data(3); fer = EEPROM_read_data(4); if(bai!=0) { write_data(bai+0x30); } write_data(shi+0x30); write_data(ge+0x30); write_data(0x2e); write_data(fyi+0x30); write_data(fer+0x30); write_data(0xdf); write_data('C'); write_com(0x85); key=1; while(1) { if(key==0) { delay(10); if(key==0) { wendu=read_temp(); wendu=wendu*2; if(wendu>=27315) { wendu=wendu-27315+530; //530 is for temperature compensation zhengshu=wendu/100; //integer part xiaoshu=wendu-zhengshu*100; //decimal part bai = zhengshu/100; shi = zhengshu%100/10; ge = zhengshu%10; fyi = xiaoshu/10; fer = xiaoshu%10; n = number*1.0/100; EEPROM_write_data(0,bai); delay(20); EEPROM_write_data(1,shi); delay(20); EEPROM_write_data(2,ge); delay(20); EEPROM_write_data(3,fyi); delay(20); EEPROM_write_data(4,fer); delay(20); } if(bai!=0) { write_data(bai+0x30); } write_data(shi+0x30); write_data(ge+0x30); write_data(0x2e); write_data(fyi+0x30); write_data(fer+0x30); write_data(0xdf); //write_data('C'); }while(!key); write_com(0x85); if(num<36.0) { blue = 0; red = 1; green = 1; } else if(num>=36.0&&num<=38.0) { green = 0; red = 1; blue = 1; } else if(num>38.0) { red = 0; green =1; blue = 1; } //Voice broadcast send_oneline(shi*10); WT558D_Delay1ms(500); if(ge!=0) { Send_oneline(ge); WT558D_Delay1ms(300); } Send_oneline(56); WT558D_Delay1ms(300); send_oneline(fyi); WT558D_Delay1ms(300); Send_oneline(fer); WT558D_Delay1ms(600); if(num<36.0) { Send_oneline(58); } else if(num>=36.0&&num<=38.0) { Send_oneline(59); } else if(num>38.0) { Send_oneline(57); } } } } //Serial port interrupt void serial() interrupt 4 { uint wendu; //Store the read value uint xiaoshu,zhengshu; //Store decimals and integers uchar ge,shi,bai,fyi,fer; //Store the first digit of the unit, ten, hundred, fraction, and the second digit of the fraction double num; uchar start = Usart_Read(); if(start =='s') { wendu=read_temp(); wendu=wendu*2; if(wendu>=27315) { wendu=wendu-27315+530; //530 is for temperature compensation zhengshu=wendu/100; //integer part xiaoshu=wendu-zhengshu*100; //decimal part bai = zhengshu/100; shi = zhengshu%100/10; ge = zhengshu%10; fyi = xiaoshu/10; fer = xiaoshu%10; Usart_Write(shi+0x30); Usart_Write(ge+0x30); Usart_Write('.'); Usart_Write(fyi+0x30); Usart_Write(fer+0x30); n = number*1.0/100; EEPROM_write_data(0,bai); delay(20); EEPROM_write_data(1,shi); delay(20); EEPROM_write_data(2,ge); delay(20); EEPROM_write_data(3,fyi); delay(20); EEPROM_write_data(4,fer); delay(20); } if(bai!=0) { write_data(bai+0x30); } write_data(shi+0x30); write_data(ge+0x30); write_data(0x2e); write_data(fyi+0x30); write_data(fer+0x30); write_data(0xdf); //write_data('C'); }while(!key); write_com(0x85); if(num<36.0) { blue = 0; red = 1; green = 1; } else if(num>=36.0&&num<=38.0) { green = 0; red = 1; blue = 1; } else if(num>38.0) { red = 0; green =1; blue = 1; } //Voice broadcast send_oneline(shi*10); WT558D_Delay1ms(500); if(ge!=0) { Send_oneline(ge); WT558D_Delay1ms(300); } Send_oneline(56); WT558D_Delay1ms(300); send_oneline(fyi); WT558D_Delay1ms(300); Send_oneline(fer); WT558D_Delay1ms(600); if(num<36.0) { Send_oneline(58); } else if(num>=36.0&&num<=38.0) { Send_oneline(59); } else if(num>38.0) { Send_oneline(57); } }
Previous article:Design of IC card intelligent water meter control system based on single chip microcomputer
Next article:The MCU host measures the temperature through DS18B20, and the slave receives and displays the temperature in real time
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Sha Zhanyou's new monolithic switching power supply design and application technology
- Study Help Post
- stm32L011D3P6 program download problem
- LTC3631EMS8E 12V to 5V circuit schematic
- How to measure the exact time of OVP and UVP triggering with BQ30Z55
- TMS320DM642StudyReport
- W806 Lianshengde 9.9 yuan development board experience 3 --- littlevgl8.0 transplantation display success
- [Open Source] Test Program Introduction - Crazy Shell Development Board Series
- [2022 Digi-Key Innovation Design Competition] [PLC based on the Internet of Things] --- Design background and goals
- [NUCLEO-L452RE Review] +Serial Port Interrupt Receive