Let’s take a look at applications of multiple sensors:
• Why use multiple sensors?
Then, we’ll get straight into programming!
Why use multiple sensors?
That’s an easy one! For the same reason we [humans]
have multiple senses. Adding a new sensor to a robot is
literally giving it another sense. Sensors are extremely
helpful in most cases — though it’s important that you
don’t overload your robot with too many sensors.
Otherwise, your programming will become overly complex.
How can we determine what
sensors to use?
Consider what goal you’re trying to accomplish when
considering what sensors to use. Look at the environment
your robot will be working in. Are there markings on the
floor it could follow with a light sensor? Are there walls it
could detect with a touch sensor? Is there a sound it could
approach using a sound sensor?
If you’re having trouble deciding on what sensors to
use, try making a bulleted list of every element of the
environment your robot is performing the challenge in.
Your list might look something like:
• Challenge mat
Now make sub-bullets for each one, describing possible
sensor uses. Like this:
- Ultrasonic sensor: Sense distance from walls
- Touch sensor: Follow walls
- Light sensor: Detect whether on floor or
• Challenge mat
- Light sensor: Follow lines on challenge mat
- Ultrasonic sensor: Detect nearby objects
The MINDSTORMS NXT kit has several variations, and
within them, several software variations. This article is based
on the NXT kit available from LEGO Education, rather than
the retail version. Additionally, the software used in this
article is the MINDSTORMS Education NXT Programming
version 2.0. That said, if you have a different kit or different
software, have no fear — chances are you’ll be fine. Just
know that you’re on your own with technical issues.
Once you’ve made an exhaustive list of possible sensor
uses, determine which sensor or sensors would be simplest
and most efficient to use to complete the challenge at
hand, and go for it!
What are the best uses of
While not necessarily related to using multiple sensors,
dynamic variables are another powerful tool in making
complex programs with the NXT. A variable is a piece of
information in your code that can change based on your
needs. There are three types of variables in programming
and their equivalents in the NXT software:
• Binary (Logic)
Binary or logic variables are either true or false. One
prevalent example of a binary variable is using a touch
sensor — either it is pressed (True) or depressed (False). You
can also use binary variables to make “conditional
statements” like “If the variable is true, continue the loop; if
the variable is false, terminate the program.”
Boolean or number variables are numbers. When you
tell your light sensor what value of light to look for, you’re
using a boolean variable. They’re primarily used for storing
values from sensors — as well as doing math — and storing
the results. For this reason, boolean variables are commonly
used in the NXT software to convert sensor values into
numbers for things like steering. For instance, if we wanted
to make a robot with a sound sensor that would go in a
straight line if it got a reading of 50(%), turn hard left at 0,
and turn hard right at 100, we’d need to create a formula
to translate those numbers into 0, -100, and 100
respectively, and use a “data wire” to connect the output to
SERVO 11.2010 37