I have added so many conditions because, when i enter the data from the switches(Increment/decrement), i am storing the value in a integer type. But we need to write BCD value to RTC DS1307. Suppose if i want to update the Minute register with 19, with out the above conditions it is updating as 11.
I hope you all understand my query.
I feel the above code is not efficient, i want to write it with out so many if conditions. Can somebody help me in this regard please?
It's not clear why you need to add multiples of 6.
If you type DS1307 in the search box, it reveals 450 results, so it's highly likely
at least one of them will help you with this device.
There is also this URL which shows in
some extreme detail how to use the DS1307. The microcontroller used was an
AVR device and not an 8051, but that is not relevant.