Sometimes it is inconvenient to carry a mobile phone, but you want to know the time. In this case, you can use a buzzer to make an audio time reminder, which will send a reminder every 60 seconds. The reminder timing can be done using the microcontroller's timer T0 and T1. The timing timer uses T1 and works in mode 2 (8-bit automatic loading). The system operation prompt timer uses T0 and works in mode 1 (16-bit timing) The code is as follows #include "reg52.h" #define uint unsigned int #define uchar unsigned char #define time_set0 5000//Set the timing length of timer 0 #define th0 (65536-time_set0)/256//Calculate the high 8 bits of the timer to load the value #define tl0 (65536-time_set0)%256 //Calculate the low 8-bit load value of the timer #define time_set1 256-200//Set the timing length of timer 1 sbit P1_1=P1^1;//System running indicator pin sbit beep=P1^7;//Buzzer pin uint cnt=0;//Counter uint cnt2=0;//Counter uint cnt3=0;//Counter void delay(uint i)//Delay function { uchar k; for(;i>0;i--) for(k=0;k<200;k++); } timer0()interrupt 1 using 1//Timer 0 setting { cnt++;//Increase one for each interrupt if(cnt>100)//Counting time 5ms*100=500ms { cnt=0; } TH0=th0;//Reinstall the timer TL0=tl0; } timer1()interrupt 3 using 2 //Timer 1 settings { cnt2++; if(cnt2>=5000)//Counting time 0.2ms*5000=1s { cnt2=0; cnt3++;//Second counter increases by one P1_1=!P1_1;//The indicator light flips once per second } } void main() { TMOD=0x21;//Set timer 1 mode 2 (high 4 bits 0010, automatic reload TH->TL, count to 255), timer 0 mode 1 (low 4 bits 0001, 16-bit timer, can count to 65535) TH0=th0;//Load timer initial value TL0=tl0; TH1=time_set1; TL1=time_set1; EA=1;//Turn on general interrupt ET0=1;//Turn on timer 0 interrupt ET1=1;//Turn on timer 1 interrupt TR0=1;//Turn on timer 0 TR1=1;//Turn on timer 1 while(1) { if(cnt3>=60)//Count down for 60 seconds { cnt3=0;//Reset the timer beep=0;//Turn on the buzzer delay(100);//Delay 100 beep=1;//Turn off the buzzer } } }