... | ... | @@ -189,6 +189,37 @@ |
|
|
>
|
|
|
> #### Results
|
|
|
>
|
|
|
> The dataLogger revealed the sound profile of a clap (see graph). With this in mind we made a program for the robot.
|
|
|
> The program ClapCar.java is familiar with the clap sound profile and once a clap is detected the robot will play a
|
|
|
> sound (see video).
|
|
|
>
|
|
|
>```
|
|
|
while (!Button.ESCAPE.isDown()) {
|
|
|
soundLevel = sound.readValue();
|
|
|
|
|
|
LCD.drawInt(soundLevel, 4, 10, 0);
|
|
|
dl.writeSample(soundLevel);
|
|
|
|
|
|
outerloop: if (soundLevel < 50) {
|
|
|
for (int i = 0; i < 24; i++) { // Sound must peak within 25 ms.
|
|
|
Thread.sleep(1);
|
|
|
soundLevel = sound.readValue();
|
|
|
if (soundLevel > 85) { // New peak in sound profile
|
|
|
for (int y = 0; y < 250; y++) { // Sound must drop within 250 ms
|
|
|
soundLevel = sound.readValue();
|
|
|
Thread.sleep(1);
|
|
|
if (soundLevel < 50) { // Sound has dropped
|
|
|
Sound.twoBeeps(); // Beeps twice to indicate a clap
|
|
|
break outerloop; // 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)
|
|
|
>
|
|
|
> ---
|
... | ... | @@ -237,7 +268,7 @@ |
|
|
> from terminating once the escape button was pressed. By implementing the ButtonListener we made the program
|
|
|
> terminate properly.
|
|
|
>
|
|
|
> # References
|
|
|
> ## References
|
|
|
>
|
|
|
> Video:
|
|
|
> http://youtu.be/UMSrPEmQrwE
|
... | ... | |