khatus
Member level 3
Question) This is the problem of a pic microcontroller. In this problem, PIC16f877A Microcontroller Pin 0-5 of port B, indicates the value from 1 to 6 of a ludo dice. PIN-0 of PORTC is taken as a pushbutton input. when the push button is pressed At that moment the LEDs connected to Pin 0-5 of port B will display the indicated value of the ludo dice.
My problem is when I press the push button (in Proteus simulation) only one LED is on. But the LED is not displaying the value indicated by the LED at that moment. What's wrong with my code?
My problem is when I press the push button (in Proteus simulation) only one LED is on. But the LED is not displaying the value indicated by the LED at that moment. What's wrong with my code?
Code:
void main()
{
static unsigned int var;
TRISC.F0=1;
TRISB=0x00;
PORTB=0x00;
while(1)
{
for ( var =1 ; var <=63; var = (var<<1) +1)
{
PORTB = var;
delay_ms(500);
PORTB = 0;
delay_ms(500);
if( !PORTC.F0)
{
PORTB = var;
break;
}
else
continue;
}
}
}