Values from Electret Microphone

Arduino and Electric Mic break out board

Arduino and Electric Mic break out board

I finally got some values from the Breakout board for electret microphone through the arduino using the simple AnalogInSerial example and a an analog/digital pull up code generously provided by CNMAT. My coding wasn’t cooperating for some time but I finally got the mic to send a reading. I have to practically scream into the microphone to pick up a change in signal. Base line is about 500 and rises as I speak louder into the microphone. Max is 1023.

Arduino code:

inline void digitalPullup(byte pin, boolean b) {  pinMode(pin, INPUT);  digitalWrite(pin, b?HIGH:LOW); }
#if defined(__AVR_ATmega1280__)
inline void analogPullup(byte pin, boolean b) { digitalPullup(pin+54,b); }
#else
inline void analogPullup(byte pin, boolean b) { digitalPullup(pin+14,b); }
#endif

void setup() {
Serial.begin(9600);
pinMode(clearred, OUTPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);

analogPullup(0, true); // enable the 20kOhm pull-up on analog pin 0
}

void loop() {
// read the analog input into a variable:
int analogValue = analogRead(0);
// print the result:
Serial.println(analogValue);
// wait 10 milliseconds for the analog-to-digital converter
// to settle after the last reading:
delay(200); //slow enough to examine the values. Yell registers higher than 500 at about 1023.
}

Advertisements

2 thoughts on “Values from Electret Microphone

  1. Hi man, I need your help!!

    First I need to be sure that the arduino code is’s correct.

    #################################
    I print in the serial, the value read in the board, using this sketch:

    void setup(){
    Serial.begin(9600);
    }

    void loop(){

    Serial.println(analogRead(0));
    delay(300);
    }
    ############################
    but don’t have a regularity

    Thanks very much for your atention

    • Hi Dene,
      I apologize for the delay getting back to you. I’ve been traveling across country.
      The arduino code I posted worked fine for my particular project – but you know how that goes, it may not work depending on exactly what you’re doing and using! I hope you’ve found a solution (I’m sure you have by now 🙂 Best of luck.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s