sound level detector using arduino and microphone

You can make a simple sound level detector without using sound detector module for arduino.
You can add more LEDs.
The sensitivity can change by changing the number that written after "sig>" in program code for each color.


Code:

#define MIC A0

int sig = 0;

void setup() {
 pinMode(2, OUTPUT);
 pinMode(3, OUTPUT);
 pinMode(4, OUTPUT);
 pinMode(5, OUTPUT);
}

void led() {
 sig = analogRead(MIC)*50;

 if (sig>1)  {digitalWrite(2, HIGH);} else {digitalWrite(2, LOW);}
 if (sig>300) {digitalWrite(3, HIGH);} else {digitalWrite(3, LOW);}
 if (sig>800) {digitalWrite(4, HIGH);} else {digitalWrite(4, LOW);}
 if (sig>950) {digitalWrite(5, HIGH);} else {digitalWrite(5, LOW);}
}

void loop() {
 led();
}

Comments

Popular posts from this blog

Digital Multimeter working principle; DMM working

A2XWY; A2XFY Cables meaning; XLPE cables advantages over PVC cables

Wireless voltmeter using Arduino and RF 433MHz receiver and transmitter