Values from Electret Microphone
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.
}
Tags: arduino, art, audio, electret microphone, flexinol, interactive, memory alloy, MFA, microcontrollers, muscle wire, nitinol, sensing, Thesis, Wearables
You can skip to the end and leave a response. Pinging is currently not allowed.
June 11, 2011 at 5:48 pm
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
July 29, 2011 at 3:53 pm
Hi Dene,
Best of luck.
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