How to Use Sound Sensor With Arduino

by STEAM-DIY in Circuits > Arduino

61 Views, 0 Favorites, 0 Comments

How to Use Sound Sensor With Arduino

Screenshot 2024-10-14 084707.png

Welcome back to my blog. We discussed servo motors in a previous post. Do you remember it? We presented 11 articles on Arduino basics. If you have not read those articles yet, please read them. I will hope to present Nodemcu lessons in the next articles.OK let’s go to today’s post. Today we are going to talk about the sound sensor.

What is the Sound sensitive sensor?

It is a sound recognition sensor. The sound sensor includes a condenser microphone. It is used to recognize sounds. If you want to change the sound recognition range, you can use the sensor’s preset controller. This sensor cannot detect sounds separately. There are other sensors on the market that are suitable for that. This sensor has three pins. It is VCC, GND, and OUT pins. VCC and GND pins are used to power up the sensor and the OUT pin is used to get output. Using this sensor we can get the digital value. We can get 0 when this sensor detects noise and 1 when it is not. We can connect this sensor to any digital pins on your Arduino board. Using this sensor we can create amazing projects. We will discuss those projects in the following articles. Today we are doing a project to blink an LED bulb using this sound sensor. The required components are given below.

Supplies

  1. Arduino Nano board — 
  2. Sound sensitive sensor — 
  3. LED bulb — 
  4. 220-ohm Resistor — 
  5. Breadboard — 
  6. Jumper wire

circuit 3.png
1435165613.png
Arduino-Nano.jpg
Sound sensitive sensor.png
220 ohm register.png
circuit.png
circuit2.png

components

circuit.png

Please attach the components to your breadboard.


Ok, Let’s look at the code.

  1. The complete program of this project –
void setup() {
pinMode(2, INPUT);//define arduino pin
pinMode(3, OUTPUT);//define arduino pin
Serial.begin(9600);//enable serial monitor
}
void loop() {
bool pulse = digitalRead(2);//Get the value and put into the variable
if (pulse == 0) {
digitalWrite(3, HIGH);//LED on
Serial.println("ON");//print serial monitor "ON"
} else {
digitalWrite(3, LOW);//LED OFF
Serial.println("OFF");//print serial monitor "OFF"
}
}

Let’s identify this code one by one. This code sets the second pin as the input pin and the third pin as the output pin.

void setup() {
pinMode(2, INPUT);//define arduino pin
pinMode(3, OUTPUT);//define arduino pin
Serial.begin(9600);//enable serial monitor
}

This code reads the sensor value and puts it in the Boolean variable. The variable name is ‘pulse’.

bool pulse = digitalRead(2);

The digital value is checked using the IF condition. The LED bulb turns on when the digital value is 0. The LED bulb turns off when the digital value is 1.

Now, select the board and port. After, click the upload button.


Now you can test this project. 

Please subscribe my channel . thanks