{"id":212,"date":"2014-12-02T05:04:35","date_gmt":"2014-12-02T05:04:35","guid":{"rendered":"http:\/\/guceret.com\/wp\/?p=212"},"modified":"2014-12-02T09:32:29","modified_gmt":"2014-12-02T09:32:29","slug":"arduino-sound-detection-with-fc-04-sensor","status":"publish","type":"post","link":"https:\/\/guceret.com\/wp\/?p=212","title":{"rendered":"Arduino sound detection with  FC-04 sensor"},"content":{"rendered":"<p>Using FC-04 to detect sound in an environment. The threshold can be changed with the potentiometer. <\/p>\n<p><!--more--><\/p>\n<p>The sensor can detect the intensity of the sound environment. The sensitivity is adjustable with the potentiometer.<br \/>\nThe working voltages are 3.3 V to 5 V and the output works as a digital switch output (1  and 0 ). <\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\r\n\/*\r\nFC-04 sound detection sensor\r\nVCC to arduino 5v GND to arduino GND\r\n\r\n*\/\r\n\r\n#define led_1 52\r\n#define led_2 53\r\n#define sound 7\r\nint vol = 0; \r\nlong time_1, time_2; \r\nint cont = 0;\r\n\r\nvoid setup() {\r\n  Serial.begin (9600);\r\n  pinMode(led_1, OUTPUT);\r\n  pinMode(led_2, OUTPUT);\r\n  digitalWrite(led_1, LOW);\r\n  digitalWrite(led_2, HIGH);\r\n}\r\n\r\n\r\nvoid loop() {\r\n\r\n  vol =  analogRead(sound);\r\n  Serial.println(vol);\r\n  delay(200);\r\n  time_2 =  millis();  \r\n  \r\n  if ( vol &gt; 500  &amp;&amp; cont == 0 ){ \r\n    digitalWrite(led_1, HIGH);\r\n    digitalWrite(led_2, LOW);\r\n    time_1 = millis();\r\n    cont = 1;\r\n  }\r\n  if ( vol &lt; 500 &amp;&amp; ( time_2 &gt;= time_1 + 2000) ) {\r\n      digitalWrite(led_1, LOW );\r\n      digitalWrite(led_2, HIGH);\r\n      cont = 0; \r\n  }\r\n  \r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using FC-04 to detect sound in an environment. The threshold can be changed with the potentiometer.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-arduino"],"_links":{"self":[{"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":5,"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":225,"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions\/225"}],"wp:attachment":[{"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guceret.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}