We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi i've got this problem can some out there help please, i'm to write a code for alarm sitting in the project that i'm doing,basically i'm to write a code that will inform some one that its time to take medication, in the morning,afternoon and night, everyday. and the other is to inform someone hourly everyday as well.
#int TIMER1 void TIMER1 isr() { Ticker-=65536; // Decrement ticker by clocks per interrupt if(Ticker<65536) // If second has expired { Ticker+=TIMER1 FREQUENCY; // Increment ticker by clocks per second seconds++; // Increment number of seconds }
//--Optional part start---
if(Seconds==60){Minutes++;Seconds=0; if(Minutes==60){Hours++;Minutes=0; if(Hours==24){Days++;Hours=0; if((Days==29&&Month==2&& !IS LEAP(year)) ||(Days==30&&Month==2) ||(Days == 31&&(Month == 4||Month == 6||Month == 9||Month == 11 ))
||(Days==32) ){Month++;Days=0;} if(Month==13){year++;Month=0;}
}}}
// ---Optional part end--- */
}}
On one hand, there is (at least) one bug in the code. How many months do you have in a year?
Second - do you feel that the code is readable. How about formatting it according to the information available directly about the message input box?
Third - you can modify your timer interrupt so it doesn't require long integers. Remember that the 8051 chip can't handle 32-bit integers natively.
Fourth - did you have a question?