티스토리 뷰
3pin Voice Sound Detection Sensor Control in Arduino: The Ultimate Guide with source code
코딩나우 2023. 2. 8. 10:193pin Voice Sound Detection Sensor Control in Arduino: The Ultimate Guide with Source Code
Arduino is a popular open-source platform for hobbyists and makers to create electronics projects. The versatility of Arduino comes from the availability of a wide range of sensors, actuators, and other components that can be used to build projects of all kinds. In this article, we'll be focusing on the 3pin Voice Sound Detection Sensor and how to control it using the Arduino platform.
What is a 3pin Voice Sound Detection Sensor?
The 3pin Voice Sound Detection Sensor is a simple and low-cost sensor that can be used to detect sound and voice. It is designed to detect sound levels in the range of 50-110 decibels and output an electrical signal in response to detected sound. This sensor is typically used in projects where sound detection is required, such as home automation, security systems, and other similar applications.
How does the 3pin Voice Sound Detection Sensor work?
The 3pin Voice Sound Detection Sensor works by converting sound waves into an electrical signal. When sound waves reach the microphone element of the sensor, it converts the sound waves into an electrical signal that can be processed by the microcontroller. The electrical signal is then processed by the microcontroller to determine the sound level, and the output pin is used to indicate if the sound level exceeds a certain threshold.
How to connect the 3pin Voice Sound Detection Sensor to the Arduino?
The 3pin Voice Sound Detection Sensor has three pins: VCC, GND, and Signal. To connect the sensor to the Arduino, follow these steps:
- Connect the VCC pin of the sensor to the 5V pin of the Arduino.
- Connect the GND pin of the sensor to the GND pin of the Arduino.
- Connect the Signal pin of the sensor to one of the digital pins of the Arduino.
Writing the Arduino Code for the 3pin Voice Sound Detection Sensor
Now that the sensor is connected to the Arduino, it's time to write the code to control the sensor. The code will read the signal from the sensor and turn on an LED if the sound level exceeds a certain threshold. Here is the code:
const int sensorPin = 2; // the pin that the sensor is attached to
const int ledPin = 13; // the pin that the LED is attached to
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledPin, OUTPUT); // set the LED pin as an output
}
void loop() {
sensorValue = analogRead(sensorPin); // read the value from the sensor
// if the sound level exceeds a certain threshold, turn on the LED
if (sensorValue > 700) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}
Testing the 3pin Voice Sound Detection Sensor
To test the sensor, upload the code to the Arduino and start making some noise near the sensor.
The LED should turn on when the sound level exceeds the threshold set in the code. If the LED does not turn on, double-check the wiring and make sure the code is correctly uploaded to the Arduino. If the LED is turning on even without sound, the threshold may need to be adjusted.
This code provides a basic example of how to control the 3pin Voice Sound Detection Sensor using the Arduino platform. By building upon this code, you can create more complex projects that utilize the sensor to detect sound and respond to it in various ways.