
Originally Posted by
_ab Why matters can you explain me?????
The code that I posted before last changes already worked but your way of connection of LED have given you a false impression that the output is reversed which if you connect it to a NPN transistor+relay will work correctly. If you connect a LED from +5V to RA2, then the pin need to be at 0V for the LED to light. Therefore your LED lights up when the pin is 0V. But 0V on the pin will not turn ON your relay so the relay will be OFF.
Your LED lights when in actual the relay is OFF. Got that now?
So forget about:
Code:
loopx movlw 0x04
movwf PORTA
and use the previous code instead.
Code:
loopx clrf PORTA ; clear output