Quote Originally Posted by elen-group View Post
Our circuit is not conditioned to the switch. Everytime we turn on the circuit our led comes on regardless if we use the switch or not. We tried the suggested help but still did not fix it. I am thinking that there is some issue with the if statement which is not implementing the switch we want.
Code:
DEFINE OSC 20
PortA = %00000000
TRISB = %00000000 'setup PORTB; 0 for output, 1 for input
TRISA.0=1

loop:

IF PORTA.0 = 1 Then ledon
PORTB.0=0 'turn off LED

GOTO loop

ledon:

PORTB.0=1 'light LED
PAUSE 5000 'pause for 2 seconds
PORTB.0=0 'turn off LED
GOTO loop

END
put a pulldown resistor on porta.0
and a pullup on PortB.0