Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- task main() {
- string sColor;
- int nColor;
- // Turn on the sensor
- SetSensorColorFull(IN_1);
- while (1) {
- unsigned int rawData[];
- int result = ReadSensorColorRaw(IN_1, rawData);
- // Read the numerical color value from the sensor
- nColor = Sensor(IN_1);
- // ReadSensorColorRaw(
- // Determine the color name from its number
- switch(nColor) {
- case 1:
- sColor = "Black";
- break;
- case 2:
- sColor = "Blue";
- break;
- case 3:
- sColor = "Green";
- break;
- case 4:
- sColor = "Yellow";
- break;
- case 5:
- sColor = "Red";
- break;
- case 6:
- sColor = "White";
- break;
- default: sColor = "???";
- }
- // Print the color name to the LCD screen
- ClearScreen();
- TextOut(0, 0, NumToStr(nColor) + ". " + sColor);
- TextOut(0, 8, NumToStr(rawData[0]) );
- TextOut(0, 16, NumToStr(rawData[1]));
- TextOut(0, 24, NumToStr(rawData[2]));
- // Wait until the color changes
- //while( Sensor(IN_1) == nColor );
- Wait(300);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement