void main()
{
while(1) {
//define RB1, RB2, RB3, RB4 as inputs
TRISB.B1 = 1;
TRISB.B2 = 1;
TRISB.B3 = 1;
TRISB.B4 = 1;
//define RB0 as output
TRISB.B0 = 0;
//Turn on Output RB0 if one of inputs RB1, RB2, RB3, RB4 = 1;
if(PORTB.B1 == 1) {
PORTB.B0 = 1;
}
else if (PORTB.B2 == 1) {
PORTB.B0 = 1;
}
else if (PORTB.B3 == 1) {
PORTB.B0 = 1;
}
else if (PORTB.B4 == 1) {
PORTB.B0 = 1;
}
else {
PORTB.B0 = 0; //Turn off RB0 if non of RB1, RB2, RB3, RB4 are pressed
}
}
}