Microphone sensor

The Hardware required:

-Arduino Board

-Bread Board

-Microphone sensor

-Wire

-USB Cable 

Firstly connect the three wires from microphone sensor to bread board and fourth wire to A0. 
Then connect the three single wires, Red wire from Bread board to 5V, Black wire from Bread board to GND and Green wire from Bread board to another GND.


The Code :
//Parameters
const int micPin  = AO;

//Variables
int micVal   = O;
// the setup routine runs once when you press reset:
// initialize serial communication at 9600 bits per second:
void setup() {
  //Init Serial USB
  Serial.begin(9600);
  Serial.println(F("Initialize System"));
  //Init Microphone
  pinMode(micPin, INPUT);
}

void loop() {
  readMicrophone();
}

void readMicrophone( ) { /* function readMicrophone */
  ////Test routine for Microphone
  micVal = analogRead(micPin);
  Serial.print(F("mic val ")); Serial.println(micVal);
  if (micVal > 600) {
    Serial.println("mic detected");
  }
}



Lastly the outcome:








Comments

Popular posts from this blog

LED Lights

Accessibility

Servo Motors