IcyWolfBrain
Newbie level 4
Hey guys, i need help in MikroC programming PIC16F877A processor. So i need do to increment and decrement 7 segment display with two diferrent buttons (one to increment/ other decrement) (Shematic in photo). Increment for me is working but decrement i dont know how to implement.
My Code:
My Code:
Code:
bit state, prev_state;
int i=0;
void main(){
portd=0;
trisd=0b00000000;
while(1){
state=portb.b0;
if(prev_state!=state){
if(state==0)i++;
if(i>9) i=0;
//portb=i;
prev_state=state;
}
switch(i){
case 0: portd=0b00111111; break;
case 1: portd=0b00000110; break;
case 2: portd=0b11011011; break;
case 3: portd=0b01001111; break;
case 4: portd=0b01100110; break;
case 5: portd=0b01101101; break;
case 6: portd=0b11111101; break;
case 7: portd=0b00000111; break;
case 8: portd=0b11111111; break;
case 9: portd=0b11101111; break;
}
}
}
Attachments
Last edited by a moderator: