NTX 2.0 Color sensor

Aug 17, 2010 at 10:33 AM
Edited Aug 17, 2010 at 10:34 AM

Hi, i currently use your nxt.net library and all work ;p 

But i don't find anything about the color sensor.

can you help about that ? i want to get back the value of the sensor and turn on/off the blue/green/red light.

thanks

Coordinator
Aug 18, 2010 at 8:38 AM
Hi Nephilim, Sorry, but this library was implemented at the time of NXT 1.0, when there was no color sensor available yet. Because I don't have NXT 2.0, I can't test the library with it, so I have no idea how can they work together. I'm really sorry :( György
Aug 18, 2010 at 10:15 AM

ok thanks, i'll go see in the fantom sdk or other document to find an isue. i'll see in a forum i'll can access to the color sensor to use direct command to IOmap. if i'll find something i'll be update the topic with the solution.

Aug 18, 2010 at 9:23 PM
Edited Aug 30, 2010 at 7:51 PM

Hi balassy, I found information about how to pilot the lego mindstorm nxt 2.0 color sensor.

I suppose you use the direct command from the Lego SDK to write your library.

 

you'll need to use two command, SETINPUTMODE and GETINPUTVALUE

 

at this time in the sdk they referenced only 13 type of input (0x00 to 0x0C) but there is 5 new input with the 1.28 firmware (0x0D to 0x11)

0x0D : COLORFULL -> NXT color sensor in color detector mode

0x0E : COLORRED -> NXT color sensor in Light sensor mode with red light on

0x0F : COLORGREEN -> NXT color sensor in Light sensor mode with green light on

0x10 : COLORBLUE -> NXT Color sensor in Light sensor mode with blue light on

0x11 : COLORNONE -> NXT Color sensor in Light sensor mode with no light

 

so to use the color sensor you'll have to send the SETINPUTMODE like that

byte 0 : 0x00 or 0x80

byte 1 : 0x05

byte 2 : Input port (0x00 to 0x03)

Byte 3 : Sensor type : here 0x0D

byte 4 : Sensor mode : here you must use raw mode so 0x00

 

to get the color value back you'll have to send the GETINPUTVALUE like that

byte 0 : 0x00

byte 1 : 0x07

byte 2 : Input port (0x00 to 0x03)

 

and the nxt get you back the message with the value of color detected

byte 0 : 0x02

byte 1 : 0x07

byte 2 : Status byte (0x00 if no error)

byte 3 : Input port (0x00 to 0x03)

byte 4 : Valid ? (Boolean, True(0x01) if new data value should be seen as valid data)

byte 5 : Calibrated (Boolean, True(0x01) if calibration file found) i don't test that so in message the byte is at 0x00

byte 6 : Sensor type, here 0x0D for color sensor mode

byte 7 : Sensor mode, here 0x00 for raw mode

byte 8 - 9 : Raw A/D value, here 0x00 0x00

byte 10 - 11 : Normalizer A/D Value, here 0x00 0x00

byte 12 - 13 Scaled value, here appear the value of the color

Black 0x01 0x00

Blue 0x02 0x00

Green 0x03 0x00

Yellow 0x04 0x00

Red 0x05 0x00

White 0x06 0x00

byte 14 - 15 Calibrated value, currently unused so 0x00 0x00

 

I hope all those information can help you to implement your library.

 

(sorry if my english is not very good but i'm french ;) )