How to connect two colorpal sensors at the same time to a boe?
tlflores
Posts: 6
I am trying to connect two colorpal sensors to a boe. One on each side of the robot so that a target on either side can be identified. I have no problem with one that works great. But when I connect the other I cannot get it to work also. When I try to adapt the code I get a sio already defined error or if I connect both colorpals to the same pin both do not work correctly. Does anyone know of a way that this can be done? Thanks.
Comments
'
[ I/O Definitions ]
sio PIN 15 ' Serial I/O com pin for ColorPAL.
'
[ Constants ]
' Baudrate definitions. Serial I/O must be open-drain. The ColorPAL includes
' a pullup internally.
baud CON 119 + 32768
'
[ Variables ]
red VAR Word ' Received RGB values from ColorPAL.
grn VAR Word
blu VAR Word
'
[ Initialization ]
GOSUB Reset ' Reset the ColorPAL and enter direct command mode.
'
[ Program Code ]
SEROUT sio, baud, ["= (00 $ m) !"] 'Program ColorPAL to send $ then color data.
DO
SERIN sio, baud, [WAIT("$"), HEX3 red, HEX3 grn, HEX3 blu] ' Receive RGB data back.
'turn on light for yellow
IF (red <= 255 AND red >=100) AND (grn <= 255 AND grn >= 100) AND (blu >= 0 AND blu <=100) THEN
HIGH 13
PAUSE 2000
LOW 13
ENDIF
LOOP
'
[ Subroutines ]
' Reset: Sends a long break to reset ColorPAL and enter direct command mode.
Reset:
LOW sio 'Pull sio low to eliminate any residual charge.
INPUT sio 'Return pin to input.
DO UNTIL sio : LOOP 'Wait for pin to be pulled high by ColorPAL.
LOW sio 'Pull pin low.
PAUSE 80 'Keep low for 80ms to enter Direct mode.
INPUT sio 'Return pin to input.
PAUSE 10 'Pause another 10ms
RETURN
and wire them accordingly.
Then I would make sio a variable
Then, for example, you can do the resetting, one at a time
finally, now you can
This is a good idea and I tried it but it does not work. As far as I can see a variable cannot accept a pin value. I will keep trying this to make sure. Thanks