User Tools

Site Tools


marvin:lab3

This is an old revision of the document!


Lab rapport 3

Lesson 3

In this lesson we will use the NXT sound sensor to turn the LEGO 9797 car into a sound controlled car.

Test of the Sound Sensor The purpose of this test is to make a simple test of the microfon sensitivity to sound coming from different directions. The Microfon is placed in the center of a closed room of 3x3m and a keybunddle is used as our sound generator. It was found that clapping with our hands made greater variance to the sound level, while the noise from the keybunddle proved to give quite constant sound levels. By the view of the microfon one would expect it to have more sensitivity to sounds coming from and the test proved that these expectations were true. In order to read the input of the microphone the code was modified to write the maximum value on the display whenever both the escape key and the right key on the NXT had been pressed. The modifications of the program is shown here:

SoundSensor s = new SoundSensor(SensorPort.S1);
int soundLevel, max;
 
LCD.drawString("Level: ", 0, 0);
while (! Button.ESCAPE.isPressed()) {		   
    max = 0;
    while (! Button.RIGHT.isPressed() && ! Button.ESCAPE.isPressed()) {
	soundLevel = s.readValue();
	if(soundLevel > max) max = soundLevel; 
	LCD.drawInt(max,3,7,0);
	LCD.refresh();
    }
 
    Thread.sleep(5);
}
LCD.clear();
LCD.drawString("Program stopped", 0, 0);
LCD.refresh();

The testdata is shown on the picture below, which shows the amplitudes measured s.readValue

lab3-measurement.jpg

marvin/lab3.1221814585.txt.gz · Last modified: 2008/09/19 10:56 by deva