Fun Projects for your LEGO MINDSTORMS NXT!

Home     Projects     Help     Contacts

Sensor Meter
Building: Easy
Program: Advanced

Building Instructions


To make a simple way to test all of the sensors, attach all of the motors and sensors to the NXT brick as follows:
Touch Sensor Port 1
Sound Sensor Port 2
Light Sensor Port 3
Ultrasonic Sensor Port 4
3 Motors Ports A, B, C

You can also use the program for this project with any other robot if as the sensors are connected like this.

Sensor Meter Programming

Use the Sensor_Meter program to display the values for all of the sensors, as shown below.


Using the Sensor Meter

The Sensor_Meter program displays the following information:
  1. Touch sensor "Pressed" or "Released".  Note that the "bumped" state depends on when you last asked the sensor, so that is not displayed.

  2. Current sound level heard by the sound sensor (this number changes very quickly), followed by the loudest sound level heard during the last second

  3. Current (reflected) light level from the light sensor

  4. Current distance seen by the ultrasonic sensor in cm

  5. (A, B, C) Degrees and direction recorded by the rotation sensors from the motors, as reported by the Rotation Sensor programming block.  The degrees is always a positive number, and the direction will be reported as "False" if the degrees is negative.

  6. If the left arrow, enter button, or right arrow button on the NXT brick are currently pressed, then "Left", "Enter", or "Right" will be displayed on the last line of the display.

To reset the rotation sensors back to zero, you can abort the program with the dark gray button on the NXT brick, then restart the program.



Try experimenting with different combinations of sensors, and even plugging some sensors into the wrong port to see what happens (I trust that LEGO has designed the parts so that you cannot damage a part by plugging it into the wrong port).  For example, some things that I found out were:

  • The NXT will not report two of the NXT buttons being pressed at the same time.  One button will always take precedence.  Can you determine the order of precedence of all three buttons?

  • The light and sound sensors, and their sensor programming blocks, appear to give the same signals and work the same way.  If you switch their ports (or use the wrong programming block), they still work fine.

  • If you plug a motor into a sensor port (1-4), you get some results, depending on what type of sensor you say is connected, but it's not obvious how to use the numbers in a useful way.  The numbers only appear to be useful in one direction of rotation, for example.  It would sometimes be nice to be able to use an extra motor as a rotation sensor (if all 3 motor ports are taken), if you could get useful enough results.

Get nxtprograms.com on CD!
Click here for info

Home     Projects     Help     Contacts


Copyright 2007-2011 by Dave Parker.  All rights reserved. 
All project designs, images, and programs are protected by copyright.  Please see the usage policy.