EasyManua.ls Logo

LEGO MINDSTORMS Robots - Page 70

LEGO MINDSTORMS Robots
226 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Page 73
start taskname
This command starts the named task.
stop taskname
Use this command to stop the named task.
The following program controls its outputs from main and uses another task, sing, to play some music. The sing task has to be started from main; otherwise, its commands will never be
executed.
task main() {
start sing;
while (true) {
OnFwd(OUT_A);
OnRev(OUT_C);
Wait(100);
OnFwd(OUT_C);
OnRev(OUT_A);
Wait(100);
}
}
#define SIXTH 12
#define HALF 3SIXTH
#define BEAT 2HALF
#define GRACE 6
task sing() {
PlayTone(330, 2BEAT);
Wait(2BEAT + 2SIXTH);
PlayTone(115, SIXTH);
PlayTone(208, SIXTH);
PlayTone(247, SIXTH);
PlayTone(330, SIXTH);
PlayTone(311, 2BEAT);
Wait(4SIXTH + 2BEAT + 2SIXTH);
PlayTone(115, SIXTH);
PlayTone(208, SIXTH);
PlayTone(247, SIXTH);
PlayTone(311, SIXTH);
PlayTone(277, 3BEAT);
Wait(4SIXTH + 3BEAT + HALF);
PlayTone(277, HALF);
PlayTone(311, HALF);
PlayTone(370, GRACE);
PlayTone(330, HALF);
PlayTone(311, HALF); Wait (2HALF);
PlayTone(277, HALF);
PlayTone(330, HALF);
PlayTone(220, HALF);
PlayTone(220, 2BEAT);
Wait(GRACE + 5HALF + 2BEAT + HALF);
PlayTone(247, HALF);

Table of Contents

Related product manuals