- CODE: SELECT_ALL_CODE
#define sw1 PORTBbits.RB0 // sw1 defined as input for SW1 on MB00
void main(void)
{
TRISA=0xFF;
TRISB=0xFF;
TRISC=0x00;
TRISD=0x00;
LATC=0x00;
LATD=0x00;
for(;;)
{
if(sw1==1)
{
LATC++;
}
else if (PORTA!=0x00)
{
LATD++;
}
} //for end
} //main end
change to above and it will work. You also need a 10K resistor to GND at the junction of your switch and input port.
Allen