Changes
Page history
u4099 created page: Template
authored
Mar 02, 2015
by
Daniel Jung Moltzen
Show whitespace changes
Inline
Side-by-side
Lesson3Week5.markdown
View page @
6cc57715
...
...
@@ -82,6 +82,33 @@ The goal is to implement a ButtonListener for the ESCAPE button, so you can exit
We are planning to do this by looking at the leJos tutorial on how to use a ButtonListener.
#### Results
```
import lejos.nxt.*;
/**
* The locomotions of a LEGO 9797 car is controlled by
* sound detected through a microphone on port 1.
*
* @author Ole Caprani
* @version 23.08.07
*/
public class SoundCtrCar
{
private static int soundThreshold = 90;
private static SoundSensor sound = new SoundSensor(SensorPort.S1);
private static void waitForLoudSound() throws Exception
{
int soundLevel;
Button.ESCAPE.addButtonListener(new ButtonListener() {
public void buttonPressed(Button b) {
LCD.drawString("escape pressed", 0, 0);
System.exit(0);
}
public void buttonReleased(Button b) {
LCD.clear();
}
});
```
#### Conclusion
...
...
...
...