anishpsla
Member level 2
- Joined
- Dec 15, 2013
- Messages
- 44
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 402
Code C - [expand] 1 2 3 4 5 6 7 8 int bump[] = {0,0,-1,1}; state = 0; state = state + PORTB.RB0; state >> 1; state = state + PORTB.RB1; level = level + bump[state]; Display_RPM(state);
The above code not working. I want to work the code something like this. I am using MikroC
consider PORTB.B0 = 1 and PORTB.B1 = 0
so state = 0b000000001 (Which is equal to 1dec)
next state = 0b00000010 + 0 = 0b00000010 (Decimal 2)
so level = 0 + bump[2] which is equal to 0+(-1)
In the above code, all the values are taken as decimal value and I am getting 10 or 20 as output.