Skip to content

Sensors

There are three types of sensors that come in a LEGO Mindstorms NXT 2.0 set.


Touch Sensor

The NXT Touch Sensor is a momentary on button. It detects when the little orange nub on the front is pushed.

Need more Touch Sensors?

Instead of getting more NXT Touch Sensors, you can use momentary-on buttons. You’ll have to wire them up and figure out how to attach them to your creation, but they’re much cheaper than buying more NXT Touch Sensors.

Connecting to Bricktronics

An NXT Touch Sensor can be connected to any sensor port on the Bricktronics Shield or the Bricktronics Megashield.

If it is placed on port 3 or 4 of the Bricktronics Shield (or any port on the Bricktronics Megashield), the jumpers should be set like the following:

Examples

Buttons are used in the ColorButton example sketch, and in the MotorButton example sketch.


Ultrasonic Sensor

The NXT Ultrasonic Sensor senses the distance between it and obstacles in front of it. It can measure from 0 to 2.5 meters in 1 centimeter resolution. The reported accuracy is around +- 3 cm. It works best when the obstacle is both big and hard (like a wall). It works with soft and squishy obstacles as well, but the accuracy is reduced–just like with other ultrasonic sensors.

Connecting to Bricktronics

The NXT Ultrasonic Sensor needs more voltage than a USB port usually can provide. It requires between 7.2V and 9V. Two good options are a 9V wall adapter (2.1mm, center-positive), or a 6xAA battery pack.

An NXT Ultrasonic Sensor can be connected to Sensor Port 3 or Sensor Port 4 on the Bricktronics Shield, or any sensor port on the Bricktronics Megashield.

The jumpers should be set like the following:

Examples

An Ultrasonic Sensor is used in the Ultrasonic example sketch.


Color Sensor


The NXT Color Sensor senses color. It can shine red, green, or blue light through its RGB LED and has an ambient light sensor. To detect the color, it shines each color in sequence, and measures how much light is reflected back, and sends those values up the wire to the Arduino. The Arduino combines them to figure out the color. The accuracy depends on a lot of factors. It works best for detecting bright colors like LEGO bricks at about 1 “stud” away, but it works with other things too.

We weren’t able to find anyone who had connected the NXT Color Sensor to their microcontroller before–but we figured it out and made it really easy using our Bricktronics hardware and software library!

Connecting to Bricktronics

An NXT Color Sensor can be connected to Sensor Port 3 or Sensor Port 4 on the Bricktronics Shield, or any sensor port on the Bricktronics Megashield.

The jumpers should be set like the following:

Examples

The Color Sensor is used in the ColorButton example sketch, ColorDebounce example sketch, and the ColorLamp example sketch.

Note: Wayne and Layne, LLC and our products are not connected to or endorsed by the LEGO Group. LEGO, Mindstorms, and NXT are trademarks of the LEGO Group.