14Tasks - Must make the task run forever Otherwise It only...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Multitasking in NQC COMP 106 Sensors • In the graphical environment, we are able to use multiple sensors using the “Sensors” blocks. • Whenever we use a new sensor block, a new “line” is created, in addition to the main line.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Tasks (threads) • Previously, we said that each sensor line runs at the same time as the main line • Each line is called a thread • Note: each sensor line runs forever! Problem • Have the robot patrol in a square forever. • During the patrol, if the right sensor is touched, play a song.
Background image of page 2
Solution With Events Better Solution (Graphical)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Better Solution (NQC)
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Must make the task run forever. Otherwise It only run once! Tasks • You can have up to 10 tasks in NQC • Must have a task named “Main” • All other tasks must be explicitly start/stop • Tasks run simultaneously Remote Control Roverbot • Two controls (4 possibilities): – Sensor 1 is released -> moves forward – Sensor 1 is pressed -> moves backward – Sensor 3 is pressed -> spin – Both Sensors are pressed -> turn off 1 1 1 1 Sensor 3 Sensor 1 • Test for all four possibilities • Make sure you stop all the other tasks to avoid conflicts...
View Full Document

{[ snackBarMessage ]}

Page1 / 5

14Tasks - Must make the task run forever Otherwise It only...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online