jessvi created page: Lab3 authored by Jesper Kurtzmann Svith's avatar Jesper Kurtzmann Svith
...@@ -194,31 +194,37 @@ ...@@ -194,31 +194,37 @@
> sound (see video). > sound (see video).
> >
>``` >```
while (!Button.ESCAPE.isDown()) { > while (!Button.ESCAPE.isDown()) {
soundLevel = sound.readValue(); > soundLevel = sound.readValue();
>
LCD.drawInt(soundLevel, 4, 10, 0); > LCD.drawInt(soundLevel, 4, 10, 0);
dl.writeSample(soundLevel); > dl.writeSample(soundLevel);
>
outerloop: if (soundLevel < 50) { > outerloop: if (soundLevel < 50) {
for (int i = 0; i < 24; i++) { // Sound must peak within 25 ms. > for (int i = 0; i < 24; i++) { // Sound must peak
Thread.sleep(1); > within 25 ms.
soundLevel = sound.readValue(); > Thread.sleep(1);
if (soundLevel > 85) { // New peak in sound profile > soundLevel = sound.readValue();
for (int y = 0; y < 250; y++) { // Sound must drop within 250 ms > if (soundLevel > 85) { // New peak
soundLevel = sound.readValue(); > in sound profile
Thread.sleep(1); > for (int y = 0; y < 250; y++) { // Sound must drop
if (soundLevel < 50) { // Sound has dropped > within 250 ms
Sound.twoBeeps(); // Beeps twice to indicate a clap > soundLevel = sound.readValue();
break outerloop; // Return to the start of the loop > Thread.sleep(1);
} > if (soundLevel < 50) { // Sound has
} > dropped
} > Sound.twoBeeps(); //
} > Beeps twice to indicate a clap
} > break outerloop; //
Thread.sleep(5); > Return to the start of the loop
} > }
``` > }
> }
> }
> }
> Thread.sleep(5);
> }
>```
> >
> [![image alt text](http://img.youtube.com/vi/UMSrPEmQrwE/0.jpg)](http://www.youtube.com/watch?v=UMSrPEmQrwE) > [![image alt text](http://img.youtube.com/vi/UMSrPEmQrwE/0.jpg)](http://www.youtube.com/watch?v=UMSrPEmQrwE)
> >
... ...
......