Page 1 of 2

Programming the Lego Colour Sensor in NXC

Posted: 19 Nov 2010, 16:33
by borntoown
Can i program a color sensor in NXC? -answered-
(yes) What should i write?

Re: Programming the Lego Colour Sensor in NXC

Posted: 19 Nov 2010, 17:02
by mightor
Please use sensible subject lines when asking for something on the forums.

There are plenty of examples on these forums of using the colour sensor. I suggest you search for it a little bit.

- Xander

Re: Programming the Lego Colour Sensor in NXC

Posted: 22 Nov 2010, 11:05
by skittler
Not a helpful subject line I agree, but I have to say I too have struggled to find any useful information on using NXC with the LEGO colour (color?) sensor on here.
Specifically, I'd like to know how to use it as a greyscale sensor.

Re: Programming the Lego Colour Sensor in NXC

Posted: 22 Nov 2010, 18:40
by mattallen37
"Colour" and "color" are both proper ways to spell the word. "Color" is the American English way, and "colour" is the UK English way. I think it's the same with gray and grey.

What do you mean by "greyscale"? You want to read it as if it was a light sensor? Just set it up as "red", instead of "full", or just read the red raw value.

Re: Programming the Lego Colour Sensor in NXC

Posted: 22 Nov 2010, 18:43
by borntoown
Well, I didnt get my help yet... :S

Re: Programming the Lego Colour Sensor in NXC

Posted: 22 Nov 2010, 18:51
by mattallen37
What do you mean you didn't get help? The answer is yes. What should you write? What do you mean by that?

Re: Programming the Lego Colour Sensor in NXC

Posted: 22 Nov 2010, 18:53
by borntoown
The command i need to write?

Re: Programming the Lego Colour Sensor in NXC

Posted: 22 Nov 2010, 21:42
by mattallen37

Code: Select all

SetSensorColorFull(S1);
Then the values returned by SENSOR_1 will be 0-6 (or something like that).

You can also use one of the following lines of code.

Code: Select all

SetSensorColorRed(S1);
SetSensorColorGreen(S1);
SetSensorColorBlue(S1);
Then the values returned by SENSOR_1 will be the RAW value for the color.

Re: Programming the Lego Colour Sensor in NXC

Posted: 27 Nov 2010, 08:40
by borntoown
The SetSensorColorFull gives an error "unidentified SetSensorColorFull". What to do?

Re: Programming the Lego Colour Sensor in NXC

Posted: 27 Nov 2010, 09:17
by mattallen37
Get the latest version of BCC.