Lesson 13 Voice Sensor

Share for us


A voice sensor module (as shown below) has two outputs:

A0: analog output, used to output voltage signals from microphone in real-time

D0: When sound intensity reaches a certain threshold, the sensor outputs high or low level (threshold can be adjusted by potentiometer)


– 1*SunFounder Uno board

– 1*USB data cable

– 1*High-Sensitive voice sensor module

– Several jumper wires

Experimental Principle

Microphone can convert audio signal into electrical signal (analog quantity), then convert analog quantity into digital value by ADC and transfer it to MCU to process. See the following figure he schematic diagram of microphone sensor module.

LM393 is a voltage comparator. When the voltage of in-phase terminal (pin 3) is higher than that of the inverting terminal (pin 2), output terminal (pin 1) will output high level signals. Otherwise, it outputs low level signals. First, adjust potentiometer to make the voltage for pin 2 of LM393 less than 5V. When there is no voice input, the resistance of the microphone is very large. The voltage for pin 3 of LM393 is close to power supply voltage (5V), pin 1 outputs high level signals and the LED is turned on; when there is voice input, the resistance of the microphone decrease, pin 1 outputs low level signals and the LED is turned off. Connect pin 1 to IO of the SunFounder Uno board to detect whether a sound is made by programming.

Experimental Procedures

Step 1: Build the circuit

Voice SensorSunFounder Uno

Step 2: Program (Please refer to the example code in LEARN -> Get Tutorials on our website)

Step 3: Compile

Step 4: Upload the sketch to the SunFounder Uno board

Now, when you speak or blow to the microphone, the LED attached to pin 13 on the SunFounder Uno board will light up.


* name:Voice Sensor
* function: you can see the value of sound intensity on Serial Monitor.
* When the volume reaches to a certain value, the LED attached to pin 13 on the SunFounder Uno board will light up.
const int ledPin = 13; //pin 13 built-in led
const int soundPin = A0; //voice sensor attach to A0void setup()
  pinMode(ledPin,OUTPUT); ////set pin13 as OUTPUT
  Serial.begin(9600); //initialize serial monitor
}void loop()
  int value = analogRead(soundPin); //read the value of voice sensor
  Serial.println(value); //print the value
  if(value > 25) //if the value is greater than 25
    digitalWrite(ledPin,HIGH); //turn on the led
    delay(2000); //delay 2s
    digitalWrite(ledPin,LOW); //turn off the led