Storing PIN into variable?
mgrey
Posts: 3
I have BS2e connected to several sensors of the same kind.
So, I want to use subroutines and select sensor before calling.
Something like this:
sensor1·CON 0
sensor2 CON 1
selectedsensor VAR Nib
selectedsensor = sensor1
getData
:
:
selectedsensor = sensor2
getData
:
:
getData:
PULSIN selectedsensor,0,Var
RETURN
According to documentation all commands taking 'Pin' can use variable as input, but the above does not work
I've tried to use PIN also, but no change!
What is the best way to solve this problem?
So, I want to use subroutines and select sensor before calling.
Something like this:
sensor1·CON 0
sensor2 CON 1
selectedsensor VAR Nib
selectedsensor = sensor1
getData
:
:
selectedsensor = sensor2
getData
:
:
getData:
PULSIN selectedsensor,0,Var
RETURN
According to documentation all commands taking 'Pin' can use variable as input, but the above does not work
I've tried to use PIN also, but no change!
What is the best way to solve this problem?
Comments
I can not get it to work!
I will do some more debugging!
Post Edited (mgrey) : 8/19/2008 6:04:54 PM GMT
The problem was that at one part of the code there was a check if a pin went low like:
DO:
:
:
LOOP WHILE sensor
this worked when sensor was defined as PIN, but of course not as CON
I solved it by:
DO
IF sensor = 0 THEN
sensorin = IN0
ENDIF
IF sensor = 2 THEN
sensorin = IN2
ENDIF
:
:
LOOP WHILE sensorin
It works but it is not so nice code!