Sure.
'else' belongs to the immediately preceding 'if'. Sometimes you have to put in a dummy else; to keep them associated.
Perhaps the old 'dangling else'?Code works for char SettingTimeOut too u know
u know the rollover part in post #108
I cannot get it done. I can get up to 255. It never decrements.
Rich (BB code):
{
Enc_New = (PORTB & 0xC0); // keep on RB7 and RB6 bits.
if(Enc_New != Enc_Old) // If Encoder moved.
{
if(Enc_New.RB7 == Enc_Old.RB6) // Check Direction.
if(TopUp_Time)TopUp_Time++; // If CW, increment TopUp.
else; // 'completes this 'if' to avoid 'dangling else'
else // was CCW
if(TopUp_Time) TopUp_Time--;// decrement TopUp.
Enc_Old = Enc_New; // Save Encoder status.
}
Int2Segs(TopUp_Time,dTime,SegDP); // update display.
}
Last edited: