Subject:
|
help with VB IR comms
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Sun, 23 Jul 2000 18:27:26 GMT
|
Viewed:
|
1220 times
|
| |
| |
Allo All
I know its not new or anything, but I was trying to set up a Robotag type game
with two RCX (is there are plural to RCX like RCXi?). One RCX (the Tagged
robot) was to sit and spin round and send out a signal. The other RCX (the
Untagged robot) was to rove about and if it picked up the signal, then send an
acknowledgment and change state to tagged. The originally tagged robot, once
it received the acknowledge signal was to then rove about etc. Nothing
original here.
I could get the tagged robot to spin around and send out the signal and the
untagged robot to move about and receive the signal and so change its state. I
ASSUME that it sent the acknowledge signal, but the originally tagged robot
did not change state to the untagged robot. Below is my code in VB (simplified
to remove the movement code). It would be great if somebody could figure out
what is wrong with my code. I tried all sorts of delays and repeating the ack
signal, but I could not get the tagged robot to change state -
------------------
Const Tagged = 10
'download code to RCX
With lego
.SelectPrgm SLOT_1
.BeginOfTask MAIN
'for slot 1 (RCX # 1), set initially untagged, for slot 2(RCX
#2), set tagged
.SetVar Tagged, CON, 0
.Loop CON, FOREVER
'if untagged
.If VAR, Tagged, EQ, CON, 0
'waiting for tag signal from other robot
.If PBMESS, 0, EQ, CON, 33
'if message received send ack
.SendPBMessage CON, 6
'"oh no, I've been caught"
.SetVar Tagged, CON, 1
.PlaySystemSound ERROR_SOUND
.EndIf
.ClearPBMessage
.EndIf
.If VAR, Tagged, EQ, CON, 1
.SendPBMessage CON, 33
'wait for ack signal
.If PBMESS, 0, EQ, CON, 6
.SetVar Tagged, CON, 0
'"yea baby yea, I'm free"
.PlaySystemSound SWEEP_UP_SOUND
.EndIf
.ClearPBMessage
.EndIf
.EndLoop
.EndOfTask
End With
---------------
Thanks in advance
Mike McFarlane
|
|
1 Message in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in Robotics
|
|
|
|