{"id":15045,"date":"2022-02-16T10:02:40","date_gmt":"2022-02-16T15:02:40","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/?p=15045"},"modified":"2022-02-16T10:03:55","modified_gmt":"2022-02-16T15:03:55","slug":"double-transducer-rotational-position-to-frequency-of-tapping","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/double-transducer-rotational-position-to-frequency-of-tapping\/","title":{"rendered":"Double Transducer: Rotational Position to Frequency of Tapping"},"content":{"rendered":"<h1><\/h1>\n<div id=\"attachment_15047\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15047\" loading=\"lazy\" class=\"size-full wp-image-15047\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Terrences-Double-transducer-scaled.jpg\" alt=\"Tingsong's Double Transducer\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Terrences-Double-transducer-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Terrences-Double-transducer-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Terrences-Double-transducer-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Terrences-Double-transducer-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Terrences-Double-transducer-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Terrences-Double-transducer-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Terrences-Double-transducer-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Terrences-Double-transducer-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15047\" class=\"wp-caption-text\">Tingsong&#8217;s Double Transducer<\/p><\/div>\n<div id=\"attachment_15209\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15209\" loading=\"lazy\" class=\"wp-image-15209 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8095-1-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8095-1-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8095-1-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8095-1-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8095-1-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8095-1-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8095-1-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8095-1-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8095-1-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15209\" class=\"wp-caption-text\">Cassie&#8217;s double transducer<\/p><\/div>\n<div id=\"attachment_15056\" style=\"width: 2305px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15056\" loading=\"lazy\" class=\"size-full wp-image-15056\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/shield.jpg\" alt=\"detail:shield\" width=\"2295\" height=\"1721\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/shield.jpg 2295w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/shield-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/shield-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/shield-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/shield-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/shield-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/shield-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/shield-508x381.jpg 508w\" sizes=\"(max-width: 2295px) 100vw, 2295px\" \/><p id=\"caption-attachment-15056\" class=\"wp-caption-text\">A shield to isolate the buzzer and sound detector from environmental noises<\/p><\/div>\n<div id=\"attachment_15207\" style=\"width: 378px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15207\" loading=\"lazy\" class=\"wp-image-15207 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8093-scaled.jpg\" alt=\"\" width=\"368\" height=\"491\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8093-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8093-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8093-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8093-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8093-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8093-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8093-508x677.jpg 508w\" sizes=\"(max-width: 368px) 100vw, 368px\" \/><p id=\"caption-attachment-15207\" class=\"wp-caption-text\">Scale to measure what angle the potentiometer is rotated to<\/p><\/div>\n<div id=\"attachment_15210\" style=\"width: 432px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15210\" loading=\"lazy\" class=\"wp-image-15210 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8096-scaled.jpg\" alt=\"\" width=\"422\" height=\"563\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8096-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8096-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8096-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8096-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8096-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8096-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8096-508x677.jpg 508w\" sizes=\"(max-width: 422px) 100vw, 422px\" \/><p id=\"caption-attachment-15210\" class=\"wp-caption-text\">Cute person attached to the servo<\/p><\/div>\n<div style=\"width: 620px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-15045-1\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Double-Transducer.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Double-Transducer.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Double-Transducer.mp4<\/a><\/video><\/div>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-15045-2\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Transducer.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Transducer.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Transducer.mp4<\/a><\/video><\/div>\n<h1>Narrative Description<\/h1>\n<p>When the potentiometer is turned it tells the buzzer to make sound and then the noise sensor listens to this sound and tells the servo to move its arm up and down once per second. When the potentiometer is turned more, the buzzer makes more noise and the servo moves its arm up and down twice per second. When the potentiometer is turned even more, the buzzer makes more noise and the servo moves its arm up and down three times per second. The Arduino lets the different pieces talk to each other and lets us change what they are saying to each other using coding.<\/p>\n<h1>Process Pictures<\/h1>\n<div id=\"attachment_15164\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15164\" loading=\"lazy\" class=\"size-full wp-image-15164\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/buzzer-and-detector-scaled.jpg\" alt=\"\" width=\"2560\" height=\"2114\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/buzzer-and-detector-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/buzzer-and-detector-300x248.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/buzzer-and-detector-1024x846.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/buzzer-and-detector-768x634.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/buzzer-and-detector-1536x1269.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/buzzer-and-detector-2048x1692.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/buzzer-and-detector-973x804.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/buzzer-and-detector-508x420.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15164\" class=\"wp-caption-text\">Testing buzzer&#8217;s frequency and volume range to ensure the sound detector sensitive enough to detect the volume change<\/p><\/div>\n<div id=\"attachment_15206\" style=\"width: 396px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15206\" loading=\"lazy\" class=\"wp-image-15206 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8091-scaled.jpg\" alt=\"\" width=\"386\" height=\"515\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8091-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8091-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8091-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8091-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8091-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8091-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_8091-508x677.jpg 508w\" sizes=\"(max-width: 386px) 100vw, 386px\" \/><p id=\"caption-attachment-15206\" class=\"wp-caption-text\">Testing different materials and how well they muffle sound<\/p><\/div>\n<div id=\"attachment_15211\" style=\"width: 391px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15211\" loading=\"lazy\" class=\"wp-image-15211 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7872-scaled.jpg\" alt=\"\" width=\"381\" height=\"508\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7872-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7872-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7872-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7872-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7872-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7872-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7872-508x677.jpg 508w\" sizes=\"(max-width: 381px) 100vw, 381px\" \/><p id=\"caption-attachment-15211\" class=\"wp-caption-text\">Process of labeling and organizing board<\/p><\/div>\n<div id=\"attachment_15212\" style=\"width: 368px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15212\" loading=\"lazy\" class=\"wp-image-15212 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7873-scaled.jpg\" alt=\"\" width=\"358\" height=\"477\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7873-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7873-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7873-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7873-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7873-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7873-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_7873-508x677.jpg 508w\" sizes=\"(max-width: 358px) 100vw, 358px\" \/><p id=\"caption-attachment-15212\" class=\"wp-caption-text\">Sound shield just after being constructed<\/p><\/div>\n<h1>Discussion<\/h1>\n<p>This project, while seemingly simple, was very difficult to make work. Conceptually both of us understood what it took to make this double transducer, but there were a lot of small issues that had to be overcome.<\/p>\n<p>At the beginning of this project, Tingsong had suggested using a solenoid to create our tapping action, and looking back we wish that we had at least tried this method instead of going right to a servo. While a servo might be conceptually simpler, we ran into a lot of issues towards the end of our project with our servos. The largest was tackling the issue of not being able to use both the servo library and the buzzer library when coding. We ended up coding directly to the servo without using the library, but there were a lot of small complications that came from this. We also had two servos that acted completely differently despite using the same code.<\/p>\n<p>There were also some issues that came with using the buzzer and the noise sensor. The noise sensor was having a lot of interference from ambient noise sources that threw off our results, especially with picking up noise from our servo instead of only the buzzer. We combated this with a small box to isolate the noise sensor and the buzzer and even experimented with different materials and what would block outside noise most effectively. We overcame this issue, but we spent a while thinking that a separate problem was due to the noise sensor detecting ambient sound, so this ended up confusing us and wasting time.<\/p>\n<p>Despite the issues that we ran into, we both learned a lot from this project. Tingsong taught Cassie about some coding things that she was inexperienced with, and Cassie helped Tingsong solder for the first time. The wiring and mechanical side of this project was surprisingly easy and without issue other than the two servos that behaved differently. We worked very well as a team and stayed upbeat despite the setbacks.<\/p>\n<p>&nbsp;<\/p>\n<h1>Functional Block Diagram<\/h1>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-15122\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Diagram-Block-3.drawio.svg\" alt=\"\" width=\"487\" height=\"376\" \/><\/p>\n<h1>Electrical Schematic<\/h1>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-15162\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Diagram-Schematic-3.jpg\" alt=\"\" width=\"981\" height=\"801\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Diagram-Schematic-3.jpg 981w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Diagram-Schematic-3-300x245.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Diagram-Schematic-3-768x627.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Diagram-Schematic-3-973x794.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Diagram-Schematic-3-508x415.jpg 508w\" sizes=\"(max-width: 981px) 100vw, 981px\" \/><\/p>\n<h1>Code<\/h1>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/*Project Title: Double Transducer: Rotational Position to Frequency of Tapping\r\n  Team Members: Casandra Rausch, Tingsong (Terrence) Ou\r\n  Description: Using potentiometer to change the rotational angle, the angle range was limited to 0 to 90 degrees.\r\n               Changing the rotational angle increases\/decreases the Buzzer's volumn\r\n               Sound detector detecting the Buzzer's volumn then map it to 0-1023 input read range\r\n               Arduino mapping the value from sound detector to [500, 250, 166], which are delay times for different frequency\r\n               Servo read delay and perform tapping, 500 delay causes 1 tapping per second, 250 causes 2, and 166 causes 3\r\n             \r\n  Pin mapping:\r\n    Arduino pin | role   | description\r\n    ------------|--------|-------------\r\n    A0            input     Potentiometer\r\n    A1            input     Sparkfun Sound Detector\r\n    6             output    Servo for simulation tapping frequency\r\n    9             defined   Buzzer (one connection)\r\n    10            defined   Buzzer (another connection)\r\n*\/\r\n\r\n#include &lt;toneAC.h&gt; \/\/Library for buzzed\r\n\/\/Libries for LCD\r\n#include &lt;Wire.h&gt;\r\n#include &lt;LiquidCrystal_I2C.h&gt;\r\n\r\n\/\/Creating LCD\r\nLiquidCrystal_I2C screen(0x27, 16, 2);\r\n\r\n\/\/Define pins\r\nconst int potenPIN = A0,\r\n          sndDetPIN = A1,\r\n          tapperPIN = 6;\r\n\r\n\/\/I tested several frequencies and found 1500 is\r\n\/\/responsive to the change of volume\r\nconst int defFreq = 1500,\r\n          LCDLow = 0,\r\n          LCDHigh = 99,\r\n          volLow = 0,\r\n          volHigh = 10,\r\n          initTestPeriod = 2000; \/\/Test time in void step() part\r\n\r\nint detLow = 1023,  \/\/initialize detected lowest value (as large as possible)\r\n    detHigh = 0;  \/\/initialize detected highest value (as small as possible)\r\n\r\nint potenLCD = 0;\r\nint buzzerLCD = 0;\r\nint sndDetLCD = 0;\r\n\r\n\/\/creating a timer for LCD\r\nunsigned long lastTime = 0;\r\nunsigned long LCDInterval = 250; \/\/refreahing LCD every 250 milliseconds\r\n\r\n\r\n\r\nvoid setup() {\r\n  \/\/Initializing LCD\r\n  screen.init();\r\n  screen.home();\r\n  screen.backlight();\r\n\r\n  pinMode(potenPIN, INPUT);\r\n  pinMode(sndDetPIN, INPUT);\r\n  pinMode(tapperPIN, OUTPUT);\r\n\r\n  Serial.begin(9600);\r\n\r\n\r\n  \/*Buzzer should first play sound in Lowest and Highest volumes\r\n    such that sound detector can generate lower bound and higher bound\r\n    of sound range*\/\r\n  int counter = 0;\r\n  while (counter &lt; initTestPeriod) {\r\n    if (counter &lt; initTestPeriod \/ 2) {\r\n      toneAC(defFreq, volLow);\r\n      delay(1);\r\n      int sndRecVal = analogRead(sndDetPIN);\r\n      if (sndRecVal &lt; detLow) detLow = sndRecVal;\r\n    } else {\r\n      toneAC(defFreq, volHigh); \/\/Offset\r\n      delay(1);\r\n      int sndRecVal = analogRead(sndDetPIN);\r\n      if (sndRecVal &gt; detHigh) detHigh = sndRecVal;\r\n    }\r\n    counter ++;\r\n  }\r\n  detHigh *= 0.75;\r\n  toneAC(defFreq, volLow);\r\n  delay(100);\r\n\r\n}\r\n\r\n\r\n\r\nvoid loop() {\r\n  \/\/reading value from potentiometer, convert to volumn\r\n  int potenVal = analogRead(potenPIN);\r\n  int buzzerVol = map(potenVal, 0, 1023, volLow, volHigh);\r\n  toneAC(defFreq, buzzerVol);\r\n\r\n  \/\/detecting volumn\r\n  int sndRecVal = analogRead(sndDetPIN);\r\n  \/\/converting read value to delaytime\r\n    int delayTime = 1000;\r\n    if (sndDetLCD &lt; 30){\r\n      delayTime = 500;\r\n    } else if (sndDetLCD &lt; 70){\r\n      delayTime = 250;\r\n    } else{\r\n      delayTime = 166;\r\n    }\r\n\r\n  \/\/Running servo\r\n  runServo(delayTime);\r\n  \r\n  int servoLCD = 0;\r\n  if (delayTime == 500) servoLCD = 0;\r\n  else if (delayTime == 250) servoLCD = 50;\r\n  else servoLCD = 99;\r\n\r\n  \/\/Displaying Values on LCD\r\n  displayOnLCD(potenVal, buzzerVol, sndRecVal, servoLCD);\r\n}\r\n\r\n\r\n\/*\r\n  -----------------------HELPER FUNCTIONS--------------------\r\n*\/\r\n\r\nvoid runServo(int delayTime){\r\n  servoWrite(tapperPIN, 30);\r\n  delay(delayTime);\r\n  servoWrite(tapperPIN, 60);\r\n  delay(delayTime);\r\n}\r\n\r\n\r\n\/\/Maping values to 0-99 range then displaying on LCD\r\nvoid displayOnLCD(int potenVal, int buzzerVol, int sndRecVal, int servoLCD) {\r\n  if (millis() - lastTime &gt;= LCDInterval) {\r\n    \/\/Map read values to LCD values (0 - 99);\r\n    potenLCD = map(potenVal, 0, 1023, LCDLow, LCDHigh);\r\n    buzzerLCD = map(buzzerVol, volLow, volHigh, LCDLow, LCDHigh);\r\n    sndDetLCD = map(sndRecVal, detLow, detHigh, LCDLow, LCDHigh);\r\n    sndDetLCD = constrain(sndDetLCD, LCDLow, LCDHigh);\r\n\r\n    screen.clear();\r\n    screen.home();\r\n    screen.print(\"i:\");\r\n    screen.print(potenLCD);\r\n    screen.setCursor(6, 0);\r\n    screen.print(\"m:\");\r\n    screen.print(buzzerLCD);\r\n    screen.setCursor(8, 1);\r\n    screen.print(sndDetLCD);\r\n    screen.setCursor(12, 1);\r\n    screen.print(\"o:\");\r\n    screen.print(servoLCD);\r\n    lastTime = millis();\r\n  }\r\n}\r\n\r\n\r\n\r\n\/\/ Reference: Robert Zacharias (class instructor)\/\/\r\n\/\/ function to drive servo motor without need for servo library\r\n\/\/ sample use: servoWrite(SERVOPIN, 50);\r\nvoid servoWrite(int servoPin, byte servoDegree){\r\n  pinMode (servoPin, OUTPUT); \/\/ in case it's not already set\r\n\r\n  const int INTERPULSEDELAY = 20; \/\/ typical delay between servo pulses\r\n \r\n  static unsigned long lastPulseTime;\r\n\r\n  if (millis() - lastPulseTime &gt; INTERPULSEDELAY){\r\n   \r\n    \/\/ turn degree input to pulse length output\r\n    unsigned int pulseWait = map(servoDegree, 0, 180, 544, 2400);\r\n\r\n    \/\/ transmit pulse of specified length\r\n    digitalWrite(servoPin, HIGH);\r\n    delayMicroseconds(pulseWait);\r\n    digitalWrite(servoPin, LOW);\r\n\r\n    \/\/ reset timer\r\n    lastPulseTime = millis();\r\n  }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Narrative Description When the potentiometer is turned it tells the buzzer to make sound and then the noise sensor listens to this sound and tells the servo to&#8230;<\/p>\n","protected":false},"author":215,"featured_media":15121,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[86],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15045"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/users\/215"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/comments?post=15045"}],"version-history":[{"count":17,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15045\/revisions"}],"predecessor-version":[{"id":15222,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15045\/revisions\/15222"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media\/15121"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media?parent=15045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/categories?post=15045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/tags?post=15045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}