Cybermaster Touch Sensors

There are three of them which can be distinguished by their color. Each has a resistor in parallel to the switch:
colorresistor
yellow10kOhm
red12kOhm
white15kOhm
The Cybermaster brick can detect which switch is connected to which port from the resistors.

By connecting them in series and using a single input of an RCX in raw mode it is possible to distinguish all combinations of presses. The LEGO connectors are made for putting things in parallel, but connecting them in series is possible by half-overlapping the connectors of the cables:

[Sensors & connectors] [Closeup on connectors]

Note that the switch in the touch sensors is made from conductive rubber against two metal contacts. It can produce intermediate values if it just barely touches them, in a range of about 0.1mm. Similar things may happen if the switch is closed in the middle of a sampling. So, if you use multiple sensors on one input it might be a good idea to read the value twice to avoid confusion. A little code snippet for decoding:

#define TOUCH_SENSOR    SENSOR_1

int touch_sensor_state;

#define PRESSED_A  ((touch_sensor_state & (1 << 2)) > 0)
#define PRESSED_B  ((touch_sensor_state & (1 << 1)) > 0)
#define PRESSED_C  ((touch_sensor_state & (1 << 0)) > 0)

task main()
{
  start touch_sensor_decoder;

  target_a = TARGET_FRONT;
  target_b = TARGET_FRONT;
  target_c = TARGET_FRONT;

  // ...

}


task touch_sensor_decoder()
{
  int v;

  SetSensorType(TOUCH_SENSOR, SENSOR_TYPE_TOUCH);
  SetSensorMode(TOUCH_SENSOR, SENSOR_MODE_RAW);

  while(true){
    v = TOUCH_SENSOR;
    if(      v > 777 )  touch_sensor_state = 0;
    else if( v > 740 )  touch_sensor_state = 2;
    else if( v > 720 )  touch_sensor_state = 4;
    else if( v > 668 )  touch_sensor_state = 1;
    else if( v > 600 )  touch_sensor_state = 6;
    else if( v > 551 )  touch_sensor_state = 3;
    else if( v > 312 )  touch_sensor_state = 5;
    else                touch_sensor_state = 7;
  }
}

// Cybermaster touch sensors connected in series, raw values
// raw  r y w  state
// 805  o o o    0
// 750  o x o    2
// 733  x o o    4
// 707  o o x    1
// 629  x x o    6
// 573  o x x    3
// 530  x o x    5
//  98  x x x    7


Jürgen <juergen@free.fr>
http://juergen.free.fr/lego/cybermaster-touchsensors.html
last modified Monday, 30-Jul-2001 14:24:55 CEST