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 microphone sensitivity to sound coming from different directions. The microphone is placed in the center of a closed room of 3x3m and a key bundle 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 key bundle proved to give quite constant sound levels. By the view of the microphone 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 test data is shown on the picture below, which shows the amplitudes measured s.readValue

lab3-measurement.jpg

The maximum readings were 93, and normal background noise were measured to 5-10.

lab3-movie.jpg

marvin/lab3.1221818027.txt.gz · Last modified: 2008/09/19 11:53 by rieper