#include#define uint unsigned int #define uchar unsigned char sbit key0 = P3^0; //Time adjustment minute and second switching sbit key1 = P3^1; //time addition sbit key2 = P3^2; //time subtraction sbit lcdrw = P2^5; //Read and write operation selection, 1 for reading and 0 for writing sbit rs = P2^6; //register selection, 1 data 0 instruction sbit lcden = P2^7; //enable signal uchar code table[] = {" 2010-10-22 FRI"}; uchar code table1[] = {" 00:00:00"}; uchar count,shi,fen,miao,s1num; void delay(uint z) { uint x,y; for(x = z;x > 0;x --) for(y = 110;y > 0;y --); } void write_com(uchar com) //write instruction { rs = 0; lcden = 0; P0 = with; delay(5); lcden = 1; delay(5); lcden = 0; } void write_date(uchar date) //write data { rs = 1; lcden = 0; P0 = date; delay(5); lcden = 1; delay(5); lcden = 0; } void init() { flying number; lcdrw = 0; lcden = 0; write_com(0x38); write_com(0x0c); write_com(0x06); write_com(0x01);//clear write_com(0x80); //LCD first line address for(num = 0;num < 15;num ++) { write_date(table[num]); delay(5); } write_com(0x80+0x40); //LCD second line address for(num = 0;num < 12;num ++) { write_date(table1[num]); delay(5); } TMOD = 0x01; TH0 = (65536-50000)/256; TL0 = (65536-50000)%256; EA = 1; // Enable interrupt ET0 = 1; //Timer 0 interrupt TR0 = 1; //Start the timer } void write_sfm(uchar add,uchar date) { flying shi,ge; shi = date/10; ge = date%10; write_com(0x80+0x40+add); write_date(0x30+shi); write_date(0x30+ge); } void keyscan() { if(key0 == 0) { delay(5); if(key0 == 0) { s1num ++; while(!key0); if(s1num == 1) { TR0 = 0; write_com(0x80+0x40+10); write_com(0x0f); } if(s1num == 2) { write_com(0x80+0x40+7); } if(s1num == 3) { write_com(0x80+0x40+4); } if(s1num == 4) { s1num = 0; write_com(0x0c); //No flash mark TR0 = 1; } } } if(s1num != 0) { if(key1 == 0) { delay(5); if(key1 == 0) { while(!key1); if(s1num == 1) { miao ++; if(miao == 60) miao = 0; write_sfm(10,miao); write_com(0x80+0x40+10); } if(s1num == 2) { fen ++; if(fen == 60) fen = 0; write_sfm(7,fen); write_com(0x80+0x40+7); } if(s1num == 3) { it ++; if(shi == 24) it = 0; write_sfm(4,shi); write_com(0x80+0x40+4); } } } if(key2 == 0) { delay(5); if(key2 == 0) { while(!key2); if(s1num == 1) { if(miao == 0) { miao = 60; write_sfm(10,miao); write_com(0x80+0x40+10); } miao --; write_sfm(10,miao); write_com(0x80+0x40+10); } if(s1num == 2) { if(fen == 0) { fen = 60; write_sfm(7,fen); write_com(0x80+0x40+7); } fen --; write_sfm(7,fen); write_com(0x80+0x40+7); } if(s1num == 3) { if(shi == 0) { it = 24; write_sfm(4,shi); write_com(0x80+0x40+4); } he --; write_sfm(4,shi); write_com(0x80+0x40+4); } } } } } void main() { heat(); while(1) { keyscan(); // while(1); } } void timer0() interrupt 1 { TH0 = (65536-50000)/256; TL0 = (65536-50000)%256; count ++; if(count == 20) { count = 0; miao ++; if(miao == 60) { miao = 0; fen ++; if(fen == 60) { fen = 0; it ++; if(shi ==24) { it = 0; } write_sfm(4,shi); } write_sfm(7,fen); } write_sfm(10,miao); } }
Previous article:Infrared tax calculator based on single chip microcomputer
Next article:Infineon MCU XC866-2FR infrared receiving program (state machine)
Recommended ReadingLatest update time:2024-11-16 17:56
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
- How does the program execute from the reset sequence to the main function?
- [AutoChips AC7801x motor demo board review] + Motor drive - BLDC sensorless method
- EEWORLD University ---- Practical Projects for IoT Embedded Engineers
- AC 220v to DC 24v (LM7824CT)
- Today's live broadcast! How to design high-performance servo drives using Infineon IGBT7
- STM32MP157A-DK1 Evaluation + HelloWorld and GPIO (2)
- Design Guide for RF Impedance Matching: Playing with the Smith Chart
- The difference between VCC, VDD, VEE and VSS in the circuit
- Recommendation: Displacement Sensor Selection
- What are the methods for upgrading the msp430 microcontroller program?