hello guys, so last time i asked how to make a counter, i solved the bouncing problem, but now i cant make it to decrease the count on the output, how can i do it? here's the code i wrote
int i;
bit o1;
bit o2;
void main() {
//////////////////////////////////////////////////////////////////////////////
trisa = 1;
porta = 0;
trisb = 0;
portb = 0;
o1 = 0;
o2 = 0;
i = 0;
//////////////////////////////////////////////////////////////////////////////
while(1){
if (Button(&PORTA,0,1,1)){
o1 = 1;
}
if(o1 && Button(&PORTA,0,1,0)){
i ++;
o1 = 0;
}
if(Button(&PORTA,1,1,1)){
o2 = 1;
}
if(o2 && Button(&PORTA,1,1,0)){
i --;
o2 = 0;
}
switch(i++){
case 1 : rb0_bit = 1; break;
case 2 : rb1_bit = 1; break;
case 3 : rb2_bit = 1; break;
}
switch(i--){
case 1 : rb0_bit = 1; break;
case 2 : rb1_bit = 1; break;
case 3 : rb2_bit = 1; break;
}
}
}