You could use PIN numbers instead of PORT.bit.
Code:
InputSelect VAR PORTB.0
myPIN VAR BYTE
Test:
IF InputSelect = 1 THEN
myPIN = 1 ; PORTB.1 selected
ELSE
myPIN = 2 ; PORTB.2 selected
ENDIF
HIGH myPIN
PAUSE 500
LOW myPIN
PAUSE 500
GOTO Test
Or, a similar version.
The Inputselect will always read 0 or 1. Add 1 to it to make 1 or 2, for PORTB.1 and PORTB.2.
Code:
InputSelect VAR PORTB.0
myPIN VAR BYTE
Test:
myPIN = InputSelect + 1
HIGH myPIN
PAUSE 500
LOW myPIN
PAUSE 500
GOTO Test
The ports used depends on the chip you are using.
Check the .bas file for the PIC you are using in the PBP folder. (ex. 16F877a.bas)
PORTL and TRISL determine which PORT that pin numbers 0-7 go to.
PORTH and TRISH determine which PORT that pin numbers 8-15 go to.
<br><br>
Bookmarks