I can't remebmer where i saw a post before say the 'Color sensor' in NXT 2.0 is a superset for 1.0's light sensor, means the 2.0 sensor can detect the light power and the colors, and acts as the simple lamp. and I believe that becasue there's 3 'LED' in the sensor, please correct me if i got wrong...
the code is simple, I just want to implenment the function of enviroment light power and color detection.
Code: Select all
task main(){
//SetSensorColorNone(S3);
SetSensorColorFull(S3);
while(true){
ReadSensorColorEx(S3, cval, rawData, normData, scaledData);
ClearScreen();
NumOut(0, LCD_LINE2, scaledData[0]);
NumOut(0, LCD_LINE3, scaledData[1]);
NumOut(0, LCD_LINE4, scaledData[2]);
switch (cval)
{
case 1 :
TextOut(0, LCD_LINE1, "black");
break;
case 2 :
TextOut(0, LCD_LINE1, "blue");
break;
case 3 :
TextOut(0, LCD_LINE1, "green");
break;
case 4 :
TextOut(0, LCD_LINE1, "yellow");
break;
case 5 :
TextOut(0, LCD_LINE1, "red");
break;
case 6 :
TextOut(0, LCD_LINE1, "white");
break;
default :
TextOut(0, LCD_LINE1, "Unknow value:");
NumOut(80, LCD_LINE1, cval);
}
Wait(50);
}
}
I'm new here, so very confused about the parameter ' normData, scaledData' here, and when and why need to turn on the different LEDs(Red, Green, Blue), I know the 'rawData' is a value(rgb) to unique desribe one color, and 'cval' is a simplified and pre-defined by LEGO base on the rgb value.
for this code, if i use 'SetSensorColorNone(S3);', the
Code: Select all
NumOut(0, LCD_LINE2, scaledData[0]);
NumOut(0, LCD_LINE3, scaledData[1]);
NumOut(0, LCD_LINE4, scaledData[2]);
always show a constant. what's the different with the ColorFull and ColorFull?
please help to clarify.
thanks lot.
this is shawn.