write_week(week); //Specify the weekly data display content
temp=(week)/10*16+(week)%10; //Convert decimal to DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x8a,temp); //Write the adjusted week data BCD code to the week register 8aH in DS1302
write_1302(0x8e,0x80); //Open write protection
write_1602com(yh+0x0e);//Because the LCD mode is set to write data, the pointer automatically increases by one, so the cursor needs to return to its original position
break;
*/
case 3:ri++;
if((yue==1)||(yue==3)||(yue==5)||(yue==7)||(yue==8)||(yue==10)||(yue==12))
{
if(ri==32)
ri=1;
}
else
{
if(yue==2)
{
if(p_r==1)
{
if(ri==30)
ri=1;
}
else
{
if(ri==29)
ri=1;
}
}
else
{
if(ri==31)
ri=1;
}
}
Conver_week(nian,yue,ri);
write_week(week);
write_nyr(9,ri); //Let LCD display the set date data in the correct position
temp=(ri)/10*16+(ri)%10; //Convert decimal into DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x86,temp); //Write the adjusted date data BCD code to date register 86H in DS1302
write_1302(0x8e,0x80); //Open write protection
write_1602com(yh+10);//Because the LCD mode is set to write data, the pointer automatically increases by one, so the cursor needs to return to its original position
break;
case 2:yue++;
if(yue==13)
yue=1;
if((yue==4)||(yue==6)||(yue==9)||(yue==11))
{
if(ri>30)
ri=1;
}
else
{
if(yue==2)
{
if(p_r==1)
{
if(ri>29)
ri=1;
}
else
{
if(ri>28)
ri=1;
}
}
}
Conver_week(nian,yue,ri);
write_week(week);
write_nyr(6,yue); //Let LCD display the set month data in the correct position
temp=(yue)/10*16+(yue)%10; //Convert decimal into DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x88,temp); //Write the adjusted month data BCD code to month register 88H in DS1302
write_1302(0x8e,0x80); //Open write protection
write_1602com(yh+7);//Because the LCD mode is set to write data, the pointer automatically increases by one, so the cursor needs to return to its original position
break;
case 1:nian++;
if(nian==100)
ours=0;
nian_temp=2000+nian;
if((nian_temp%400==0)||((nian_temp%100!=0)&&(nian_temp%4==0))) //Judge whether it is a leap year
p_r=1;
else
p_r=0;
Conver_week(nian,yue,ri);
write_week(week);
write_nyr(3,nian); //Let LCD display the set year data in the correct position
temp=(nian)/10*16+(nian)%10; //Convert decimal into DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x8c,temp); //Write the adjusted year data BCD code to the year register 8cH in DS1302
write_1302(0x8e,0x80); //Open write protection
write_1602com(yh+4);//Because the LCD mode is set to write data, the pointer automatically increases by one, so the cursor needs to return to its original position
break;
}
}
}
//------------------Decrease key dec, refer to the 'add key' comment for each sentence function---------------
if(dec==0)
{
delay(10); //Adjust delay to eliminate jitter
if(dec==0)
{
led1=0;
collection=0;
buzzer=0; //The buzzer beeps once
delay(20);
buzzer=1;
while(!dec);
switch(setn)
{
case 6:
miao--;
if(miao==-1)
miao=59; //When the second data is reduced to -1, it will automatically become 59
write_sfm(0x06,miao); //Display the new seconds after the change in the correct position of the LCD
write_1602com(er+7); //Because the LCD mode is set to write data, the pointer automatically increases by one, so here it is written back to the original position
Previous article:51 MCU Proteus simulation 320x240TFT color screen
Next article:Microcontroller breathing light program and waveform demonstration
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- What will happen if the servo motor inertia is insufficient?
- How to select parameters for servo motor inertia size
- The difference between the servo motor moment of inertia and the load moment of inertia
- Analysis of the working principles of seven triode collector DC circuits 3
- Explore RF challenges and solutions for the connected car
- 40 Years of Mobile Base Station History
- 【RT-Thread Reading Notes】Network Framework
- What's wrong with the bends/corners of the Kicad chip leads?
- EEWORLD University ---- Introduction to LED functions and considerations for LED driver design
- CC2630 TIMAC protocol stack low power consumption issue
- Temperature Problems Solved for You (VI) Design Challenges of Wearable Temperature Sensing
- Advanced tips for analog and vector signal generators
- 【TI Recommended Course】#Smart Building Wireless Solutions#