Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #pragma config(Sensor, S4, Colour, sensorEV3_Color, modeEV3Color_Ambient)
  2. #pragma config(Motor, motorB, motorLeft, tmotorEV3_Large, PIDControl, encoder)
  3. #pragma config(Motor, motorC, motorRight, tmotorEV3_Large, PIDControl, encoder)
  4. //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
  5.  
  6. /*
  7. Colour sensor modes
  8. 0 - modeEV3Color_Reflected
  9. 1 - modeEV3Color_Ambient
  10. 2 - modeEV3Color_Color
  11. 3 - modeEV3Color_Reflected_Raw
  12. 4 - modeEV3Color_RGB_Raw
  13. 5 - modeEV3Color_Calibration - Not utilized
  14. */
  15.  
  16. task main()
  17. {
  18. while (true)
  19. {
  20. // Write the amount of reflected light to the screen
  21. // This is a value between 0 and 100, where 0 means no reflected
  22. // light and 100 means all light is being reflected
  23. displayBigTextLine(4, "Reflected: %d", SensorValue[Colour]);
  24.  
  25. if(SensorValue[Colour] < 20)
  26. {
  27. motor[motorLeft] = 20;
  28. motor[motorRight] = 20;
  29. }
  30. else
  31. {
  32. motor[motorLeft] = -50;
  33. motor[motorRight] = 50;
  34. sleep(750);
  35. motor[motorLeft] = 100;
  36. motor[motorRight] = 100;
  37. sleep(1000);
  38. }
  39.  
  40. // Wait 20 ms to get 50 readings per second
  41. sleep(20);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement