Lesson 7 – Microphone code example

This is the Code to Lesson 7 – that show how to work with Microphone and detect noise, it also explain about Microphone Board behavior and setup

//Lesson 7 – Arduino Microphone

// By Roee Bloch
//All right Reserved
// Copyright (c) 2015 All Right Reserved, http://www.electronics-freak.com
//
// This source is subject to the Roee Bloch License.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Roee Bloch</author>
// <email>roeebloch@walla.co.il</email>
// <date>June 2015</date>

#define Mic 0
#define LED 7
int val;
char state = 0; // state for Led if 1 LED is on
void setup()
{
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
}
void loop()
{
  val = analogRead(Mic);
  if (val & gt; 65)
  {
    state = ~state;
    digitalWrite(LED, state);
    delay(1000);
  }
  Serial.print(“MIC value is: ”);
  Serial.println(val);
  delay(50);
}

This example shows how to use Microphone and catch sound

[adsenseyu6]

[adsenseyu1]