{"id":28678,"date":"2016-11-17T23:22:15","date_gmt":"2016-11-17T23:22:15","guid":{"rendered":"http:\/\/randomnerdtutorials.com\/?p=28678"},"modified":"2019-04-02T10:23:30","modified_gmt":"2019-04-02T10:23:30","slug":"guide-for-microphone-sound-sensor-with-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/guide-for-microphone-sound-sensor-with-arduino\/","title":{"rendered":"Guide for Microphone Sound Sensor with Arduino"},"content":{"rendered":"<p>This post shows how to use the microphone sound sensor with the Arduino board.<!--more--><\/p>\n<h2>The Microphone Sound Sensor<\/h2>\n<p><span style=\"font-weight: 400;\">The microphone sound sensor, as the name says, detects sound. It gives a measurement of how loud a sound is.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"> There are a wide variety of these sensors. \u00a0<\/span>In the figure below you can see the most common used with the Arduino.<\/p>\n<h2><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-28679\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=562%2C406&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"sound-sensor\" width=\"562\" height=\"406\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?w=700&amp;quality=100&amp;strip=all&amp;ssl=1 700w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=150%2C108&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=300%2C217&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=80%2C58&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=220%2C159&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=138%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 138w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=208%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 208w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=329%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 329w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=574%2C415&amp;quality=100&amp;strip=all&amp;ssl=1 574w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?resize=674%2C487&amp;quality=100&amp;strip=all&amp;ssl=1 674w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><\/h2>\n<p>At the leftmost side,\u00a0you can see the KY-038 and at the right the LM393 microphone sound sensor.<\/p>\n<p>Both sensor\u00a0modules have a built-in potentiometer to adjust the sensitivity of the digital output pin.<\/p>\n<h2>Where to buy?<\/h2>\n<p>You can go to <a href=\"https:\/\/makeradvisor.com\/tools\/microphone-sound-sensor-ky-038\/\" target=\"_blank\" rel=\"noopener noreferrer\">Maker Advisor<\/a> and find the sensor&#8217;s best price.<\/p>\n<ul>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/microphone-sound-sensor-ky-038\/\" target=\"_blank\" rel=\"noopener noreferrer\">Sound sensor<\/a><\/li>\n<\/ul>\n<h2>Pin wiring<\/h2>\n<p><span style=\"font-weight: 400;\">Wiring your sensor to the Arduino is pretty straightforward:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Pin<\/strong><\/td>\n<td><strong>Wiring to Arduino<\/strong><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">A0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Analog pins<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">D0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Digital pins<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">GND<\/span><\/td>\n<td><span style=\"font-weight: 400;\">GND<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">VCC<\/span><\/td>\n<td><span style=\"font-weight: 400;\">5V<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If you&#8217;re using the LM393 module, you should connect the OUT pin to an Arduino digital pin.<\/p>\n<h2>Example: Sound Sensitive Lights<\/h2>\n<p>In this example, a microphone sensor will detect the sound intensity of your surroundings and will light up an LED if the sound intensity is above a certain threshold.<\/p>\n<h3>Parts required<\/h3>\n<p>For this example you\u2019ll need the following components:<\/p>\n<ul>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/microphone-sound-sensor-ky-038\/\" target=\"_blank\" rel=\"noopener noreferrer\">1x Microphone sound sensor<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/compatible-arduino-uno-r3-board\/\" target=\"_blank\" rel=\"noopener noreferrer\">Arduino UNO<\/a>\u00a0\u2013 read\u00a0<a href=\"https:\/\/makeradvisor.com\/best-arduino-starter-kits\/\" target=\"_blank\" rel=\"noopener noreferrer\">Best Arduino Starter Kits<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\" rel=\"noopener noreferrer\">1x Breadboard<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/3mm-5mm-leds-kit-storage-box\/\" target=\"_blank\" rel=\"noopener noreferrer\">1x LED<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\" rel=\"noopener noreferrer\">1x 220 Ohm resistor<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\" rel=\"noopener noreferrer\">Jumper wires<\/a><\/li>\n<\/ul>\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n<h3>Schematics<\/h3>\n<p>Assemble all the parts by following the schematics below:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter wp-image-28691\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=512%2C735&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"microphone-sound-sensor_bb\" width=\"512\" height=\"735\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?w=676&amp;quality=100&amp;strip=all&amp;ssl=1 676w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=104%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 104w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=209%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 209w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=56%2C80&amp;quality=100&amp;strip=all&amp;ssl=1 56w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=153%2C220&amp;quality=100&amp;strip=all&amp;ssl=1 153w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=70%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 70w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=166%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 166w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=289%2C415&amp;quality=100&amp;strip=all&amp;ssl=1 289w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=339%2C487&amp;quality=100&amp;strip=all&amp;ssl=1 339w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/microphone-sound-sensor_bb.png?resize=414%2C595&amp;quality=100&amp;strip=all&amp;ssl=1 414w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/p>\n<h3>Code<\/h3>\n<p>Upload the following code to your Arduino board.<\/p>\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n * Rui Santos \n * Complete Project Details http:\/\/randomnerdtutorials.com\n*\/\n\nint ledPin=13;\nint sensorPin=7;\nboolean val =0;\n\nvoid setup(){\n  pinMode(ledPin, OUTPUT);\n  pinMode(sensorPin, INPUT);\n  Serial.begin (9600);\n}\n  \nvoid loop (){\n  val =digitalRead(sensorPin);\n  Serial.println (val);\n  \/\/ when the sensor detects a signal above the threshold value, LED flashes\n  if (val==HIGH) {\n    digitalWrite(ledPin, HIGH);\n  }\n  else {\n    digitalWrite(ledPin, LOW);\n  }\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Arduino_microphone_sensor.ino\" target=\"_blank\">View raw code<\/a><\/p>\n<h3>Demonstration<\/h3>\n<p>After uploading the code, you can clap next to the sensor. If the LED is not lighting up, you need to change the sensor sensitivity by rotating the potentiometer.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter size-full wp-image-28696\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/Demo-GIF.gif?resize=480%2C270&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"demo-gif\" width=\"480\" height=\"270\" \/><\/p>\n<p>You can also adjust the sensitivity so that the LED follows the beat of a certain music.<\/p>\n<p>Add more LEDs for a more spectacular effect!<\/p>\n<h2>Wrapping up<\/h2>\n<p>I hope you&#8217;ve found this guide useful.<\/p>\n<p>What ideas do you have to use the sound sensor module?<\/p>\n<p>Let me know by posting a comment down below.<\/p>\n<p>If you&#8217;d like to know more about arduino sensor modules, make sure you take a look at the following posts:<\/p>\n<ul>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/guide-for-bmp180-barometric-sensor-with-arduino\/\" target=\"_blank\" rel=\"noopener noreferrer\">Guide for BMP180 Barometric Sensor with Arduino<\/a><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/guide-for-real-time-clock-rtc-module-with-arduino-ds1307-and-ds3231\/\" target=\"_blank\" rel=\"noopener noreferrer\">Guide for Real Time Clock (RTC) Module with Arduino (DS1307 and DS3231)<\/a><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/guide-for-rain-sensor-fc-37-or-yl-83-with-arduino\/\" target=\"_blank\" rel=\"noopener noreferrer\">Guide for Rain Sensor FC-37 or YL-83 with Arduino<\/a><\/li>\n<\/ul>\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post shows how to use the microphone sound sensor with the Arduino board.<\/p>\n","protected":false},"author":5,"featured_media":28679,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[267,2,302,256,269,264,215,10],"tags":[],"class_list":["post-28678","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino-project","category-arduino","category-0-guide","category-electronics","category-guide-project","category-project","category-sensors","category-a-tutorials"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/10\/sound-sensor.jpg?fit=700%2C506&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/28678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=28678"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/28678\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/28679"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=28678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=28678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=28678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}