So I decided to hook up a standard LEGO 9v Light 2×1 brick to one of the OUT ports on my RCX, and see if I could get it to work. Here is the setup (and my first attempt at Leocad):The lamp doesn’t really show up well in the above picture, but it’s simply one of these.
Now basically the light needs to flash in certain patterns to transfer information. For finding out what those patterns are I need to acknowledge Doug Eaton who did a great job of figuring it all out and putting a great write-up online. Another great resource was Barnaby Walter’s page, who achieved the same using the LEGO fibre-optic elements.
I have written a rcxvll.nqh library which contains all the VLL commands the MicroScout recognizes, together with a little test program which runs a sequence of the direct commands which you can use to test connectivity.
To successfully use it all together, make sure to build your setup first, turn on the bricks, upload program to the RCX, set the MicroScout to P mode, then run the RCX program.
You can barely see the light flashing in the video, but it is!
]]>The RCX has been set up real simply with three touch sensors, one for left, one forward and one right. The programming is made pretty easy using NQC:
task main() { /* Set all three Sensor types to Touch sensors */ SetSensorType(SENSOR_1, SENSOR_TYPE_TOUCH); SetSensorType(SENSOR_2, SENSOR_TYPE_TOUCH); SetSensorType(SENSOR_3, SENSOR_TYPE_TOUCH); /* Set infrared power to High, so we can cover longer distance. */ SetTxPower(TX_POWER_HI); while(true) // Loop forever { if (SensorValue(0)==1) //button 1 pressed { SendRCMessage(RC_CHANNEL_1, RC_CMD_REV, RC_CMD_FWD); } if (SensorValue(1)==1) //button2 pressed { SendRCMessage(RC_CHANNEL_1, RC_CMD_FWD, RC_CMD_FWD); } if (SensorValue(2)==1) //button3 pressed { SendRCMessage(RC_CHANNEL_1, RC_CMD_FWD, RC_CMD_REV); } Wait(5); } }
This of course assumes your Spybotics brick has been configured to RC channel 1. Download the program: rcx2spy_remote.nqc
]]>