Check out an excellent homebrew sensor page at http://home.concepts.nl/~bvandam/sensors.html.
This is compiled from mail messages to the owner of a Mindstorms page.
Related to your input mux, but possibly more useful: You can use an
8-position joystick (of the on-off variety) and 4 resistors as a sensor.
I used an old (I do mean old) Atari joystick. It had one common pin, 4
position pins (cardinal compass directions), and a fire button. As would
be expected, the appropriate pin or pins were connected to common when the
joystick was pushed in a direction or the fire button was pressed. Note
that this means that diagonals connect two direction pins to common.
You can probably figure out the rest... Connect a resistor of the
appropriate value to each of the four direction pins, then tie their
ends to one side of a wire plate. I also connected the fire button
directly. The common pin from the joystick goes to the other side of the
wire plate.
At the time I was still using Lego's RCX coding software, so I was stuck
with treating it as a light sensor. However, I had managed to turn that
light sensor input into a 10-position switch: Joystick in the center
resulted in 0. Various directions resulted in various predictable values.
The fire button resulted in a 100. The only real catch is trying to get
four resistors that will also combine in the correct combinations
(diagonals) to always result in distinct values.
As I noted before, I could probably choose the resistors better now that I
can use raw sensor mode. These were chosen because they produced distinct
values in light sensor mode.
Top: 66k 10%
Left: 22k 5%
Bot: 33k 5%
Rght: 47k 5%
I literally sat down with a box of assorted resistors and kept trying
combinations until they came out right. Note that only the diagonals I
used (the ones that make sense on a joystick) will make sense with an
output value: it's not a perfect 'mux'.
These result in the following (light sensor mode) values: (more or less)
21
60 43
51 28
67 53
36
0 means no direction, nothing pushed. I connected the fire button without
a resistor, so 100 indicated that it was pushed. I actually used the
following ranges. They seem to work well.
0-15: stop
16-25: forward
26-32: right
33-40: back
41-47: up right
48-51: left
52-56: back right
57-63: up left
64-72: back left
73-100: fire button
If it's too much trouble to build a joystick of switches, why not pick up
an old atari joystick somewhere? They've gotta be selling pretty cheap.
Mine came with an Atari model 2600. I don't know exactly how old it is,
but the box it lives in is for a 2.4k modem. =)
It's interesting how some people are designing sensors to allow robots to
be autonomous, while I'm designing controls so I can tell it where to go.
:)
Jeremy Weatherford
xidus@xidus.net