Sound Sensor

In this project, you'll learn how to use a sound sensor to detect sound.

Parts needed:
  • Arduino
  • A sound sensor
  • Wires
Sound sensor     
1 In order for the sound sensor to work correctly, you will first need to calibrate it. First, identify the signal LED that can be turned on and off by turning the potentiometer. This is the signal LED used in the calibration and detection.
  • Turn the potentiometer fully counterclockwise.
  • When there is NO sound, slowly turn the potentiometer clockwise until the signal LED just turns off.
  • The signal LED will turn on when the sound sensor detects a sound.
2 Making the connections
  • Connect VCC on the sound sensor to 5V on the Arduino.
  • Connect GND on the sound sensor to GND on the Arduino.
  • Connect OUT on the sound sensor to pin 6 on the Arduino.
2 Create a new Bare Minimum program and type in this program.

The OUT pin from the sound sensor outputs a 0 when it detects sound and a 1 when there is no sound.

Both the signal LED on the sound sensor and the built-in led on the Arduino is turned on when there is sound and off when there is no sound.
#define ledPin 13
#define outPin 6
bool sound = false; // flag to remember whether currently there is sound or no sound
int value;          // value from the sound sensor OUT pin

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(outPin, INPUT);

void loop() {
  value = digitalRead(outPin);
  if (value == 0 && !sound) {
    Serial.println("Sound detected");
    digitalWrite(ledPin, HIGH);
    sound = true;
  } else if (value == 1 && sound) {
    Serial.println("No sound");
    digitalWrite(ledPin, LOW);
    sound = false;