Code: #define ARRAYSIZE(a) (sizeof(a)/sizeof((a)[0])) int Notes[] = { 988, 988, 0, 988, 784, 988, 1175, 0, 783, 0, 784, 0, 783, 0, 659, 0, 880, 987, 932, 880, ... }; int Durations[] = { 14, 14, 7, 27, 14, 27, 27, 27, 27, 27, 27, 14, 27, 14, 27, 14, 27, 27, 14, 27, ... }; int index = 0;
task SongTask() { while (index < ARRAYSIZE(Notes)) { if (!bSoundActive) { PlayTone(Notes[index], Durations[index]); index++; } } }
task main() { StartTask(SongTask); while (true) { // // do other robot tasks here. // } }
|