Home

NXT Color Sensor


 

HiTechnic NXT Color Sensor
Fo
r LEGOÒ MindstormsÒ NXT

 

 

Introduction

The NXT Color Sensor operates by using three different color light emitting diodes (LED) to illuminate the target surface and measures the intensity of each color reflected by the surface.  Using the relative intensity of each color reflection, the color sensor calculates a Color Number that is returned to the NXT program.

The Color Sensor connects to an NXT sensor port using a standard NXT wire and uses the digital I2C communications protocol.  The Color Number calculated by the sensor is refreshed approximately 100 times per second.

The Color Sensor is housed in a standard Mindstorms sensor housing to match the other Mindstorms elements.

To test your new sensor, plug it into port 2 of your NXT and select View > Ultrasonic cm > Port 2. Position the sensor approximately 1/4" (6mm) from a colored surface.  A Color Number in the range of 0 - 17 will be displayed.  As you move the sensor over different colored surfaces, the readings will change. (0 will display as ?????? while in View mode.)

Programming

Mindstorms NXT-G

The Color Sensor can be programmed using LEGO Mindstorms NXT Software Color Sensor Block.  If the Color Sensor Block is not available you may use the standard Ultrasonic Block.

Ultrasonic Block

If using the Ultrasonic Block to program the Color Sensor, configure the block to centimeter mode as shown.

 

The Ultrasonic Block will return the Color Number which will be in the range 0 - 17.

Color Sensor Block*^

The Color Sensor Block is designed to support the HiTechnic Color Sensor.

  

1.  This plug wires the number for which of your NXT’s ports are connected to the Color Sensor.
2.  This plug wires the lower limit number for the Inside/Outside compare function.
3.  This plug wires the upper limit number for the Inside/Outside compare function.
4.  This plug wires the Color Number.
5.  This plug outputs the relative Red value.
6.  This plug outputs the relative Green value.
7.  This plug outputs the relative Blue value.
8.  This plug outputs the Inside/Outside logical value.

Color Front Panel

Port allows you to select the NXT port the compass is plugged into.

Compare

Compares the Color Number to the range set and sets the logic value to show if the value is inside or outside the range.

 

Using Range

The Compare lets you set a range and easily determine if the Color Number is inside or outside the range.

The Components for using the Range function are;

Inside Range / Outside Range:  Select if you want to test for a Color Number inside the range or outside the range.

A: The lower limit of the range (0 – 17)

B: The upper limit of the range (0 – 17)

To use the Range function, set the lower and upper limit of your range and whether you want to test for inside or outside the range. 

Examples showing the logical result.

A

B

Range

Color Number

Logical Value

8

12

Inside Range

10

8

12

Inside Range

15

8

12

Outside Range

10

8

12

Outside Range

15

 

  

Color Number Chart

The Color Number chart shows the relationship between the target color and the Color Number returned by the Color Sensor.

Sensor Register Layout

The color firmware supports the standard Lego company’s sensor memory model.

 

Address

Type

Contents

00 – 07H

chars

Sensor version number

08 – 0FH

chars

Manufacturer

10 – 17H

chars

Sensor type

18 – 3DH

bytes

Not used

3E, 3FH

chars

Reserved

40H

byte

Not used

41H

byte

Command

42H

byte

Color number

43H

byte

Red reading

44H

byte

Green reading

45H

byte

Blue reading

46 - 47H

word

Raw red sensor reading

48 - 49H

word

Raw green sensor reading

4A – 4BH

word

Raw blue sensor reading

4CH

byte

Color index number

4DH

byte

Normalized red reading

4EH

byte

Normalized green reading

4FH

byte

Normalized blue reading

The Sensor version number field will report a revision number in the format “Vn.m” where n is the major version number and m is the revision level. Revision numbers will typically reflect the firmware level. The version number will be used to indicate the hardware level.

The Manufacturer field will contain “HiTechnc”.

The Sensor type field will contain “Color”.

The Command field reserved for future use. 

The Color number field will return a single number color estimate.

The Red, Green and Blue reading fields will return the current detection levels for the three color components.

The Raw red, green and blue reading fields will return the current sensor analog signal levels for the three color components as 10 bit values.

The Color Index Number field will return a single 6 bit number color index. Bits 5 and 4 encode the red signal level, bits 3 and 2 encode the green signal level and bits 1 and 0 encode the blue signal levels.

The Normalized red, green and blue reading fields will return the current relative levels for the three color components. The normalization sets the highest value of the three Red, Green and Blue reading to 255 and adjusts the other two proportionately.

 

Other Programming Environments

RobotC

All features of the HiTechnic Color Sensor can be accessed using RobotC.  For more information go to http://www-education.rec.ri.cmu.edu/robotc/.  

 

NBC

Next Byte Code (NBC) is a simple programming language that can access all Color Sensor features.  For more information go to http://bricxcc.sourceforge.net/nbc/.

 

Notes:

  • The HiTechnic Color Sensor operates best when positioned straight above the target surface and not at an angle to the target surface.
  • NXT Firmware version 1.03 or later must be loaded in the NXT for the compass to operate correctly.  You can check the firmware version by  displaying the NXT Window in the Mindstorms software.

 

Return to Products

 

 To contact us with questions or comments see Contact Us.                                                                                12.2d

Copyright © 2001 - 2006 HiTechnic Products.    HiTechnic Products is a division of Dataport Systems, Inc.
Lightbricks, Hitechnic are registered trademarks of Dataport Systems, Inc  Not responsible for typographical errors.  All product specifications 
and prices are subject to change at any time.

LEGO, LEGO MindStorms, Robotics Invention System, RCX are trademarks of the LEGO Group.