khatus
Member level 3
Hello guys I have taken two inputs from PORTB1 and PORTB2 pins in PIC MCU through two push buttons. And I have taken one LED output in pin PORTB0. If both inputs are 1 or 0 then LED will not light up. And if one of the two push buttons is on, it will light up. This should be done using if ... else statement. But without using Bitwise XOR operator (^) .
here is my code What is wrong with my code??
here is my simulation picture
here is my code What is wrong with my code??
Code:
void main()
{
TRISB.F0=0;
TRISB.F1=1;
TRISB.F2=1;
PORTB.F0=0;
while(1)
{
if(PORTB.F1==1)
{ if(PORTB.F2==1)
{
PORTB.F0=0;
}
}
else if(PORTB.F1==0)
{ if(PORTB.F2==0)
{
PORTB.F0=0;
}
}
else
PORTB.F0=1;
}
}
here is my simulation picture