jessvi created page: Lab3 authored by Jesper Kurtzmann Svith's avatar Jesper Kurtzmann Svith
...@@ -26,35 +26,34 @@ ...@@ -26,35 +26,34 @@
> >
> We made a program similar to the SonicSensorTest called SoundSensorTest, but changed it to use the sound sensor and > get the readings using the readValue() method of the SoundSensor class. > We made a program similar to the SonicSensorTest called SoundSensorTest, but changed it to use the sound sensor and > get the readings using the readValue() method of the SoundSensor class.
> >
``` >```
public class SoundSensorTest >public class SoundSensorTest
{ >{
>
public static void main(String [] args) > public static void main(String [] args)
throws Exception > throws Exception
{ > {
> SoundSensor SS = new SoundSensor(SensorPort.S1);
SoundSensor SS = new SoundSensor(SensorPort.S1); >
> //Set to dB mode
//Set to dB mode > SS.setDBA(false);
SS.setDBA(false); >
> LCD.drawString("SoundSensor ", 0, 0);
LCD.drawString("SoundSensor ", 0, 0); > LCD.drawString("SoundLvL(dB) ", 0, 2);
LCD.drawString("SoundLvL(dB) ", 0, 2); >
> while (! Button.ESCAPE.isDown())
while (! Button.ESCAPE.isDown()) > {
{ > LCD.drawInt(SS.readValue(), 3, 13, 2);
LCD.drawInt(SS.readValue(), 3, 13, 2); >
> Thread.sleep(300);
Thread.sleep(300); > }
} > LCD.clear();
LCD.clear(); > LCD.drawString("Program stopped", 0, 0);
LCD.drawString("Program stopped", 0, 0); > Thread.sleep(2000);
Thread.sleep(2000); > }
} >}
} >
>```
```
> >
>**Results** >**Results**
> >
... ...
......