Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. mutex moveMutex;
  2. unsigned int colorArray[];
  3. bool move = false;
  4. task moveTask()
  5. {
  6. while (true)
  7. {
  8. if (move == true) {
  9. Acquire(moveMutex);
  10. OnFwd(OUT_AC, 20); Wait(500);
  11. move = false;
  12. Release(moveMutex);
  13. }
  14. }
  15. }
  16. task display()
  17. {
  18. while (true)
  19. {
  20. ReadSensorColorRaw(IN_4, colorArray);
  21. NumOut(0, 0, colorArray[0]);
  22. NumOut(0, 8, colorArray[1]);
  23. NumOut(0, 16, colorArray[2]);
  24. if (colorArray[1] > colorArray[0] && colorArray[1] > colorArray[2])
  25. {
  26. Acquire(moveMutex);
  27. move = true;
  28. Wait(500);
  29. Release(moveMutex);
  30. }
  31. }
  32. }
  33. task main()
  34. {
  35. Precedes(moveTask, display);
  36. SetSensorColorFull(IN_4);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement