I am new here and recently started playing around with microc My code is workinf fine but I do have a problem when executing a statement regarding time. I am using the DS1307 in 24 Hour Format. The clock runs fine as well as all the other code.
I have a statement that exicutes port to come ons and go off ad pre defined times the statement runs fine from 00 hours to 12 Hours and then starts behaving strange I turn port D1 on at 6 O Clock D2 at 8 and D3 at 10 and from 10 to 17:00 these should stay on until 18:00 when D3 turns of 19:00 D2 turns off and 21:00 D1 turns off.
Thus thus not happen up until 12 all is fine as soon as the clock turns over to 13:00 port D3 goes off and at 14:00 D2 goes off and 15:00 D1 goes off
Can any body direct me in the right direction regarding this.
I am using micro c V8.2
Here is the statement:
Code: Select all
if (hh>=6 && hh<8)
{
PORTD=0b00000001;
}
else if (hh>=8 && hh<10)
{
PORTD=0b00000011;
}
else if (hh>=10 && hh<19)
{
PORTD=0b00000111;
}
else if (hh>=19 && hh<20)
{
PORTD=0b00000011;
}
else if (hh>=20 && hh<21)
{
PORTD=0b00000001;
}
else if (hh>=21 && hh<=23)
{
PORTD=0b00000000;
}
else if (hh>=00 && hh<6)
{
PORTD=0b00000000;
}