void main() {
PORTB = 0x00; //initialize portb
PORTC = 0x00; //initialize portc
TRISB = 0x00; //set portb as output
TRISC = 0xFF; //set portc as input
while (1) { // Endless loop
if (PORTC.F0 == 0) // If RC0 goes to low
goto RAIN; // goto RAIN
}
RAIN:
PORTB.F0 = 1; // Set RB0 high
PORTB.F4 = 1; // Set RB4 high
Delay_ms(1000); //1 second delay
while (1) { //Endless loop
if (PORTC.F3 == 1) // Motion Detector
goto END;
if (PORTC.F4 == 0) // Over-current #1
PORTB.F0 = 0;
if (PORTC.F6 == 0) // Over-current #2
PORTB.F4 = 0;
if (PORTB.F0 == 0 & PORTB.F4 == 0)
goto END;
}
END:
PORTB.F0 = 0;
PORTB.F4 = 0;
}