Introduction: Use of Microphone Module
In this article I will talk about the mic module with the arduino.You can practice with several microphone module.There are usually one per module 4.He writes the names on p. 5V Vcc pin plugs eat GND GND pin. The other two pins AO and DO pins are made of the connection pin number defined in the code section. A0 pin to analog, the DO pin is defined as the input pin reading digitally.
Step 1: Sound Sensitive LED Control With Microphone
LED application volume is now the reference will blink for a second.
Step 2: Circuit Diagram:
Connection pins:
Microphone module >>>>Arduino
AO____________________A0
DO____________________D2
VCC __________________5V
GND__________________ GND
Led >>>>>>Arduino
Anode_____D13
Cathode___ GND
Step 3: Software Part:
// Robimek - Robotic Systems - 2016
const int DO_pin = 2;
const int AO_pin = 0;
int ses;
int led = 13;
void setup()
{
pinMode(DO_pin, INPUT);
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop()
{
if (ses > 35)
{
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
}
ses = analogRead(AO_pin);
Serial.print(digitalRead(DO_pin));
Serial.print("-");
Serial.println(analogRead(AO_pin));
}
More information : http://make.robimek.com/use-of-microphone-module-with-arduino/
2 Comments
7 years ago
good sketch but as the friend said initialize int ses = 0; if no ses could have bad data as 27272 at the beginning that´s why is better initialize the variable, and second comment is , test the Analog input
ses = analogRead(AO_pin);
then the IF statements :)
7 years ago
It might be wise to explicitly initialise ses when you declare it
replace "int ses;" by "int ses=0;"
then you can be certain that the test for ses>35 at the start of loop will always work correctly (or you can set equal to zero in setup())