0% found this document useful (0 votes)
108 views

Measure Sound Noise Level in DB With Microphone and Arduino

This Arduino code reads the value from a microphone connected to analog pin A0, converts it to decibels and prints the dB value to the serial monitor if it has changed from the previous reading. It also turns on an LED connected to pin 3 if the dB value exceeds 60, in order to indicate loud sounds.

Uploaded by

kaloy33
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views

Measure Sound Noise Level in DB With Microphone and Arduino

This Arduino code reads the value from a microphone connected to analog pin A0, converts it to decibels and prints the dB value to the serial monitor if it has changed from the previous reading. It also turns on an LED connected to pin 3 if the dB value exceeds 60, in order to indicate loud sounds.

Uploaded by

kaloy33
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

const int MIC = 0; //the microphone amplifier output is connected to pin A0

int adc;
int dB, PdB; //the variable that will hold the value read from the microphone each time
void setup() {
Serial.begin(9600); //sets the baud rate at 9600 so we can check the values the microphone is obtaining
on the Serial Monitor
pinMode(3, OUTPUT);
}
void loop(){
PdB = dB; //Store the previous of dB here

adc= analogRead(MIC); //Read the ADC value from amplifer


//Serial.println (adc);//Print ADC for initial calculation
dB = (adc+83.2073) / 11.003; //Convert ADC value to dB using Regression values
if (PdB!=dB)
Serial.println (dB);
if (dB>60)
{
digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(3, LOW);
}
//delay(100);
}

You might also like