Page 237 - The Unofficial Guide to Lego Mindstorms Robots
P. 237
226
Once you've got the resistance, and assuming you have a binary progression of resistors, you can convert the input resistance to
a bitmask of switch presses with this equation:
The bitMask will contain four bits of information, one for each switch. Each bit is 0 when the switch is closed (pressed) and
1 otherwise.
The raw input value depends on the battery voltage. As the batteries drain, the raw reading will become lower, which means
that the calculated value of R becomes lower. Adding 1/2 in the previous equation (and rounding to an integer) helps
compensate for this and allows the touch multiplexer to work until the batteries are about half-drained.
Other Neat Ideas
This chapter has presented some simple sensors you can build yourself, but there are many other possibilities. Michael
Gasperi's web site (listed in the ''Online Resources") has several outstanding ideas. Once you've built the signal splitter (Figure
11-5), you can attach any old electronic circuit to the RCX's inputs. Michael Gasperi has built several interesting sensors based
around the use of operational amplifiers (op amps).
The first of these is sound sensor. This sensor can detect sounds like hand claps; you can program your robot to respond to
sound. Basically, this circuit uses an op amp to amplify the signal from a microphone.
Michael has also built a differential light sensor. This sensor actually contains two photoresistors and some circuitry. The
circuitry interprets the signals from the two photoresistors and sends a signal to the RCX that indicates the balance of light
between the two photoresistors. This process allows you to easily build a robot that seeks light.
What About Actuators?
I've talked a lot about building sensors; why not build actuators too? LEGO only offers two actuators: motors and lights. The
lights aren't very practical and usually serve only a decorative purpose, although it's possible you could use them to signal
other robots.