Introduction
This experiment demonstrates how to detect sound frequency using a microphone sensor.
Components Needed
- Microphone Sound Sensor
- Arduino
- Jumper Wires
Circuit Setup
- Connect the VCC pin of the microphone sensor to 5V on the Arduino.
- Connect the analog output pin of the microphone to an analog input pin (e.g., A0) on the Arduino.
The microphone will capture the sound, and the Arduino will process the frequency.
Code for Sound Frequency Detection
Upload the following code to your Arduino to detect sound frequency:
const int soundPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int soundValue = analogRead(soundPin);
Serial.print("Sound Frequency: ");
Serial.println(soundValue);
delay(100);
}
Explanation
The microphone sensor converts sound into an analog voltage that the Arduino reads and outputs as a frequency value on the Serial Monitor.
Troubleshooting
- Ensure the microphone sensor is placed in a quiet environment for accurate readings.
- If no sound is detected, check the sensor’s connections and power.