Tag Archives: NQC

Controlling a Spybotics pbrick using an RCX

The LEGO MindStorms RCX is capable of sending remote control IR signals to a LEGO Spybotics brick. This opens up a ton of new possibilities, essentially giving the RCX access to two more motors (theoretically even six as you can control up to three Spybotics over different channels).

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

Share

Configuring the LEGO USB Tower on Linux

If you are a Linux user and have a Robotics Invention System (RIS) version 1.0 or 1.5, you have a serial infrared (IR) tower, which is fairly easy to set up. RIS version 2.0 came with a USB tower however, and getting that to work isn’t as straightforward. Some of these steps might seem daunting to a novice, but if you follow them correctly you should be OK.

LEGO USB IR Tower

Current versions of the Linux kernel (2.6.*) include support for the LEGO USB Tower by default. There are many Linux distributions, and they’re not all configured the same way. Below instructions were created for Ubuntu version 12.04 TLS 32-bit, one of the most popular distributions at this time. Continue reading

Share