Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. task main() {
  2. string sColor;
  3. int nColor;
  4.  
  5. // Turn on the sensor
  6. SetSensorColorFull(IN_1);
  7.  
  8.  
  9. while (1) {
  10.  
  11.  
  12. unsigned int rawData[];
  13. int result = ReadSensorColorRaw(IN_1, rawData);
  14.  
  15. // Read the numerical color value from the sensor
  16. nColor = Sensor(IN_1);
  17. // ReadSensorColorRaw(
  18.  
  19. // Determine the color name from its number
  20. switch(nColor) {
  21. case 1:
  22. sColor = "Black";
  23. break;
  24. case 2:
  25. sColor = "Blue";
  26. break;
  27. case 3:
  28. sColor = "Green";
  29. break;
  30. case 4:
  31. sColor = "Yellow";
  32. break;
  33. case 5:
  34. sColor = "Red";
  35. break;
  36. case 6:
  37. sColor = "White";
  38. break;
  39. default: sColor = "???";
  40. }
  41.  
  42. // Print the color name to the LCD screen
  43. ClearScreen();
  44. TextOut(0, 0, NumToStr(nColor) + ". " + sColor);
  45. TextOut(0, 8, NumToStr(rawData[0]) );
  46. TextOut(0, 16, NumToStr(rawData[1]));
  47. TextOut(0, 24, NumToStr(rawData[2]));
  48.  
  49. // Wait until the color changes
  50. //while( Sensor(IN_1) == nColor );
  51. Wait(300);
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement