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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
//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
Arduino Nano Ebay Link Arduino Nano Arduino Uno Ebay link Arduino Uno Arduino Mega2560 Ebay link Arduino Mega 2560 Arduino Pro-mini ebay link Arduino Pro Mini |