Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mutex moveMutex;
- unsigned int colorArray[];
- bool move = false;
- task moveTask()
- {
- while (true)
- {
- if (move == true) {
- Acquire(moveMutex);
- OnFwd(OUT_AC, 20); Wait(500);
- move = false;
- Release(moveMutex);
- }
- }
- }
- task display()
- {
- while (true)
- {
- ReadSensorColorRaw(IN_4, colorArray);
- NumOut(0, 0, colorArray[0]);
- NumOut(0, 8, colorArray[1]);
- NumOut(0, 16, colorArray[2]);
- if (colorArray[1] > colorArray[0] && colorArray[1] > colorArray[2])
- {
- Acquire(moveMutex);
- move = true;
- Wait(500);
- Release(moveMutex);
- }
- }
- }
- task main()
- {
- Precedes(moveTask, display);
- SetSensorColorFull(IN_4);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement