Skip to content

Commit d79da07

Browse files
committed
Updated sound sensor sketches.
1 parent e8cbae3 commit d79da07

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

_0510_-_Ultrasonic_Distance_Sensor/_0510_-_Ultrasonic_Distance_Sensor.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* -----------------
3030
* For information on the ultrasonic transducer: https://en.wikipedia.org/wiki/Ultrasonic_transducer
3131
* For information on ultrasounds: https://en.wikipedia.org/wiki/Ultrasound
32-
* HC-SR04 datasheet: https://docs.google.com/document/d/1Y-yZnNhMYy7rwhAgyL_pfa39RsB-x2qR4vP8saG73rE/edit
32+
* HC-SR04 datasheet: https://docs.google.com/document/d/1Y-yZnNhMYy7rwhAgyL_pfa39RsB-x2qR4vP8saG73rE
3333
* Information about the pulseIn function: https://www.arduino.cc/en/Reference/PulseIn
3434
*
3535
* Created on October 21 2016 by Peter Dalmaris

_0560_-_Analog_microphone/_0560_-_Analog_microphone.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ void loop()
5959

6060
if (millis() - timer >= sampleSpan) {
6161
volume = maxValue - minValue;
62-
// Serial.println(volume);
62+
//Serial.println(volume);
6363
resetValues();
6464
}
6565

6666
// I arbitrarily select 100 as the value above which the
6767
//microphone is picking a loud noise.
68-
if (volume > 100)
68+
if (volume > 400)
6969
{
7070
Serial.println("Loud");
7171
digitalWrite(ledpin,HIGH);

_0560_-_Digital_sound_sensor/_0560_-_Digital_sound_sensor.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ void loop ()
5555
{
5656
digitalWrite(ledpin,HIGH); // Turn the LED on to show there was a loud noise
5757
lastSoundDetectTime = millis(); // record the time of the sound alarm
58-
// The following is so you don't scroll on the output screen
58+
// This will output the LOUD message only once even if the signal remains
59+
// at HIGH. This way it will not scroll out of the window with the same message.
5960
if (!bAlarm){
60-
Serial.println("LOUD, LOUD");
61+
Serial.println("LOUD!");
6162
bAlarm = true;
6263
}
6364
}

0 commit comments

Comments
 (0)