Lego Color Sensor values

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Lego Color Sensor values

Post by HaWe »

hello,
the meaning of color values I do actually understand (RGB, e.g. raw)
#define INPUT_RED 0
#define INPUT_GREEN 1
#define INPUT_BLUE 2
But what is a "blank value" for...?
#define INPUT_BLANK 3
Access the blank value from color sensor value arrays
and what means "number of entries"?
#define INPUT_NO_OF_COLORS 4
The number of entries in the color sensor value arrays
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Lego Color Sensor values

Post by mattallen37 »

In full color mode, the FW stores the phototransistor values for when the LED is red, green, blue, and off. In full color mode, there are four LED states.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Lego Color Sensor values

Post by HaWe »

thx,
so "INPUT_BLANK 3" is sort of reflected background/ambient light?

but what's about "INPUT_NO_OF_COLORS 4"
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Lego Color Sensor values

Post by mattallen37 »

AFAIK, yes.

Well, with red, green, blue, and blank, there are four "colors", hence "INPUT_NO_OF_COLORS 4"
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Lego Color Sensor values

Post by HaWe »

well, actually no.
I mean:

Code: Select all

Color sensor array indices
Input module constants
Constants for use with color sensor value arrays to index RGB and blank return values. More...

Macros 
#define  INPUT_RED   0 
#define  INPUT_GREEN   1 
#define  INPUT_BLUE   2 
#define  INPUT_BLANK   3 
#define  INPUT_NO_OF_COLORS   4 
so:

Code: Select all

unsigned int ColorSensorRaw  ( byte  port, byte  color);

rawRed     = ColorSensorRaw(S1, INPUT_RED);
rawGreen   = ColorSensorRaw(S1, INPUT_GREEN);
rawBlue    = ColorSensorRaw(S1, INPUT_BLUE);
rawReflect = ColorSensorRaw(S1, INPUT_BLANK);
but what is THIS for?

Code: Select all

rawNumber=  ColorSensorRaw(S1, INPUT_NO_OF_COLORS); //??????????
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Lego Color Sensor values

Post by mattallen37 »

doc-helmut wrote:...
but what is THIS for?

Code: Select all

rawNumber=  ColorSensorRaw(S1, INPUT_NO_OF_COLORS); //??????????
Where did you find that line of code? ColorSensorRaw doesn't compile if you pass the constant INPUT_NO_OF_COLORS into the second parameter.

Code: Select all

# Error: compchk failed.  4 is not less than 4.
I still stand by my last reply.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Lego Color Sensor values

Post by mattallen37 »

See here.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Lego Color Sensor values

Post by HaWe »

my guess was simply, if
#define INPUT_NO_OF_COLORS 4
stands in a line with all the other constants for color macro names then it should be able to use it like the other macro constants and - above all - it should have any meaning or effect or result if it was passed to a function.

Code: Select all

#define  INPUT_RED   0
#define  INPUT_GREEN   1
#define  INPUT_BLUE   2
#define  INPUT_BLANK   3
#define  INPUT_NO_OF_COLORS   4 
why would one need a name for a constant equal to 4 which's name is as long as the hole Genesis if it has no other meaning than just "4" ?
Just to remember what "4" was like?
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Lego Color Sensor values

Post by mattallen37 »

For the same reason people use "LCD_LINE1", "OUT_A", "S3", "INPUT_RED", or any other macros. You certainly are not required to use them, if you instead prefer to enter the numeric equivalence.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Lego Color Sensor values

Post by HaWe »

ok, thx, nevertheless
#define INPUT_RED 0
#define INPUT_GREEN 1
#define INPUT_BLUE 2
#define INPUT_BLANK 3

thoroughly make sense to prevent from confusing or reversing the inputs of the color sensor value array.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests