Programming the Lego Colour Sensor in NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
borntoown
Posts: 58
Joined: 14 Nov 2010, 16:58

Programming the Lego Colour Sensor in NXC

Post by borntoown »

Can i program a color sensor in NXC? -answered-
(yes) What should i write?
Last edited by borntoown on 22 Nov 2010, 13:45, edited 2 times in total.
B2O productions are the best for the best.
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: Programming the Lego Colour Sensor in NXC

Post 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
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
skittler
Posts: 5
Joined: 31 Oct 2010, 23:38
Location: Wokingham, UK

Re: Programming the Lego Colour Sensor in NXC

Post 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.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Programming the Lego Colour Sensor in NXC

Post 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.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
borntoown
Posts: 58
Joined: 14 Nov 2010, 16:58

Re: Programming the Lego Colour Sensor in NXC

Post by borntoown »

Well, I didnt get my help yet... :S
B2O productions are the best for the best.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Programming the Lego Colour Sensor in NXC

Post 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?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
borntoown
Posts: 58
Joined: 14 Nov 2010, 16:58

Re: Programming the Lego Colour Sensor in NXC

Post by borntoown »

The command i need to write?
B2O productions are the best for the best.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Programming the Lego Colour Sensor in NXC

Post 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.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
borntoown
Posts: 58
Joined: 14 Nov 2010, 16:58

Re: Programming the Lego Colour Sensor in NXC

Post by borntoown »

The SetSensorColorFull gives an error "unidentified SetSensorColorFull". What to do?
B2O productions are the best for the best.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Programming the Lego Colour Sensor in NXC

Post by mattallen37 »

Get the latest version of BCC.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest