{"id":96,"date":"2021-11-26T23:18:15","date_gmt":"2021-11-26T23:18:15","guid":{"rendered":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/?p=96"},"modified":"2021-12-07T00:40:53","modified_gmt":"2021-12-07T00:40:53","slug":"group-project-tranquility-detector","status":"publish","type":"post","link":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/2021\/11\/26\/group-project-tranquility-detector\/","title":{"rendered":"Group Project: Tranquility Detector"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Project Aim<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Develop a noise detector that buzzes and lights up when the sound levels reach above a certain level acceptable in the tranquility room in the dining hall.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Team Members<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sulagna Saha, Yu Wati Nyi, Mumtaz Fatima<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Documentation of Our Build Process<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>Collect the required components from the Arduino Kit. The required components were: Arduino Uno kit, Breadboard, Buzzer, LED Light, Sound Sensor<\/li><li>Connect the Arduino Uno to the breadboard and make the necessary connections with the LED bulb, Buzzer, and Sound Sensor<\/li><li>Modify the code and add the functionality to activate buzzer whenever the sound sensor detects a value, it saves the value, finds the peak value, uses this value of the detected sound to convert it into volts.<\/li><li>Cardboard box:&nbsp;<ul><li>Cut cardboard to create a box with 2 open lateral ends.&nbsp;<\/li><li>Make 3 holes to add the components. One hole on the top to attach the sound sensor and 2 holes on the side to attach the LED and the buzzer<\/li><\/ul><\/li><li>Test the connections and view the serial monitor to check whether the code works as intended<\/li><li>Finally attach the breadboard to the bottom of the cardboard box and cover the 2 open ends.<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Circuit Diagram <\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"792\" src=\"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-content\/uploads\/sites\/755\/2021\/11\/pasted-image-0-1024x792.png\" alt=\"\" class=\"wp-image-97\" srcset=\"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-content\/uploads\/sites\/755\/2021\/11\/pasted-image-0-1024x792.png 1024w, https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-content\/uploads\/sites\/755\/2021\/11\/pasted-image-0-300x232.png 300w, https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-content\/uploads\/sites\/755\/2021\/11\/pasted-image-0-768x594.png 768w, https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-content\/uploads\/sites\/755\/2021\/11\/pasted-image-0.png 1219w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Code<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\n MAX4466 (adafruit mic)\n \n Written by Shani Mensing, edited by Audrey St. John\nModified by Yu Wati Nyi, Mumtaz Fatima, Sulagna Saha\n \n Circuit: microphone VCC connected to 3.3V, OUT to analog input A0\n *\/\n\n\/\/ hook up the out of the mic to analog input A0\nint MIC_IN = A0;\n\n\/\/ Sample window width in milliseconds (50 ms = 20Hz)\nint sampleWindow = 50; \nint red_light_pin= 11;\nint green_light_pin = 10;\nint blue_light_pin = 9;\nInt buzzer_pin = 8;\n\n\/**\n * Initialization code\n **\/\nvoid setup()\n{\n   \/\/ open serial port and set data rates to 9600 bps (bits-per-second)\n   \/\/ this lets us communicate to\/from the arduino\n   Serial.begin(9600);\n   \n   pinMode( MIC_IN, INPUT );\n   pinMode(red_light_pin, OUTPUT);\n   pinMode(green_light_pin, OUTPUT);\n   pinMode(blue_light_pin, OUTPUT);\n   pinMode(buzzer_pin, OUTPUT);\n}\n\n\/**\n * Main program loop happens constantly.\n **\/\nvoid loop()\n{\n    \/\/ read the analog sensor as volts\n    double soundSensed = sampleSoundPeak();\n    \n    \/\/ convert to volts\n    double volts = (soundSensed * 3) \/ 1024; \n    if(volts&lt;1){\n      RGB_color(0, 255, 0); \/\/ Green\n      delay(1000);\n    }\n    else{\n      RGB_color(255, 0, 255); \/\/ Magenta\n      delay(1000);\n      tone(buzzer_pin, 1000); \/\/ Send 1KHz sound signal...\n      delay(1000);        \/\/ ...for 1 sec\n      noTone(buzzer_pin);     \/\/ Stop sound...\n      delay(1000);\n    }\n    \n    \/\/ print it out\n    Serial.println(volts);\n}\n\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Our own methods\n\n\/**\n * Sense biggest input difference are being input from the analog MIC sensor\n * over a certain \"window\" of time. \n * Values returned are in the range 0 - 1024.\n **\/\ndouble sampleSoundPeak()\n{\n    \/\/ record start time \n    double startMillis = millis(); \n\n    \/\/ this will be the highest peak, so start it very small    \n    int signalMax = 0;\n    \n    \/\/ this will be the lowest peak, so start it very high\n    int signalMin = 1024;\n    \n    \/\/ will hold the current value from the microphone\n    int sample;\n    \n    \/\/ collect data for 50 ms\n    while ( (millis() - startMillis) &lt; sampleWindow ) \n    {\n        \/\/ read a value from mic and record it into sample variable\n        sample = analogRead( MIC_IN );\n        \n        \/\/ toss out spurious readings\n        if (sample &lt; 1024)\n        {\n        \n            \/\/ if the current sample is larger than the max\n             if (sample &gt; signalMax)\n             {      \n                   \/\/ this is the new max -- save it\n                   signalMax = sample; \n             }\n             \/\/ otherwise, if the current sample is smaller than the min\n             else if (sample &lt; signalMin)\n             {\n                   \/\/ this is the new min -- save it\n                   signalMin = sample; \n             }\n         }\n     }\n     \n     \/\/ now that we've collected our data,\n     \/\/ determine the peak-peak amplitude as max - min\n     int peakDifference = signalMax - signalMin; \n    \n     \/\/ give it back to the caller of this method\n     return peakDifference;\n}\nvoid RGB_color(int red_light_value, int green_light_value, int blue_light_value)\n{\n  analogWrite(red_light_pin, red_light_value);\n  analogWrite(green_light_pin, green_light_value);\n  analogWrite(blue_light_pin, blue_light_value);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Project Display <\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Flex project\" width=\"525\" height=\"295\" src=\"https:\/\/www.youtube.com\/embed\/-IQm9fWExDE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Project Aim Develop a noise detector that buzzes and lights up when the sound levels reach above a certain level acceptable in the tranquility room in the dining hall. Team Members Sulagna Saha, Yu Wati Nyi, Mumtaz Fatima Documentation of Our Build Process Collect the required components from the Arduino Kit. The required components were: &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/2021\/11\/26\/group-project-tranquility-detector\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Group Project: Tranquility Detector&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1806,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-96","post","type-post","status-publish","format-standard","hentry","category-project"],"_links":{"self":[{"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/users\/1806"}],"replies":[{"embeddable":true,"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":2,"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":141,"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/posts\/96\/revisions\/141"}],"wp:attachment":[{"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/commons.mtholyoke.edu\/mumtazlearns\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}