Tuesday, March 6, 2012

Using Condenser Mics with Arduino + OPAMP

Whether for a DIY clapper or an autonomous robot, condenser mics are great for use with a Arduino. But, they don't output high enough voltage for the Arduino to detect (the loudness of the sound the mix picks up varies the voltage it outputs). So, i used use a LM386 OPAMP to boost the output. Just for fun i used it to trigger an LED, which could be replaced with something fancier, say a MOC/TRIAC and a lamp etc.
Scheme
Code:

/*
 * Monitor for sound sensor
 */

int micPin = 2;    // select the input pin
int ledPin = 13;   // select the pin for the LED
int val = 0;
int amp = 0;

void setup() {
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
  Serial.begin(9600);
}

void loop() {
  val = analogRead(micPin);
  amp = (val >= 512) ? val - 512 : 512 - val; //it is a ternary operator. X = A ? B : C; if A is true X = B, otherwise C
  if (amp > 100)
  {
    digitalWrite(ledPin, HIGH);
    delay(10);
  }
  else
  {
    digitalWrite(ledPin, LOW);
  }
  Serial.println(amp);
}

3 comments:

  1. There is shocking news in the sports betting world.

    It's been said that every bettor must watch this,

    Watch this now or stop placing bets on sports...

    Sports Cash System - SPORTS CASINO ROBOT

    ReplyDelete
  2. Really very informative and creative content.
    Condenser

    ReplyDelete
  3. I was only 21 when i had akj condensor mic. i had buy condenser mic from an online store on amazon. The working experience was fabulous. Now i am 26 and again i am planning for the next generation. I will buy as soon as possible within upcoming days......

    ReplyDelete