Accessing I/O from Chuck Hellebuycks book
I have problems making this programme work. It is from Chuck Hellebuycks book which I am learning from. When I press the switch both leds go off. I have tried leaving adcon1 = 6 off
I am using 16f84a instead of 16f876
Init:
adcon1 = 6 ' Set all PortA to digital I/O
trisa = %00000001 ' set PortA RA4-RA1 to outputs, RA0 input
porta = %00000010 ' Set PortA RA1 high to turn on LED1
Main:
' *** Test the switch state ***
if portA.0 = 0 then led2 'If switch is pressed then jump to LED2 routine
PortA.1 = 1 ' Turn LED1 on
portA.2 = 0 ' Turn LED2 off
goto Main ' Jump to the top of the main loop
LED2:
'*** Turn LED2 on ***
porta.2 = 1 ' LED2 on
porta.1 = 0 ' LED1 off
goto Main ' Jump to the top of the main loop
Thanks to anybody who can help.
Now works but with 16f876 not 16f84a
I have now used 16f876 ( it works ok) instead of 16f84a I did try your sugestions but with no luck so I am going to rebuild with 16f84a again and try another pic.
Thanks for the help.
Quester.
NEW MESSAGE: I have now got it working! I rebuilt the circuit and it worked OK but one of the LEDs wasnt quite going off but I was working from the book PIC in Practice and the circuit did not show a wire to ground from Vss I fitted that and it is now OK.