{"id":12520,"date":"2021-03-10T00:54:59","date_gmt":"2021-03-10T05:54:59","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/?p=12520"},"modified":"2021-03-10T01:09:50","modified_gmt":"2021-03-10T06:09:50","slug":"double-transducer-vibration-to-movement-to-sound","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/double-transducer-vibration-to-movement-to-sound\/","title":{"rendered":"Double Transducer: Vibration to Movement to Sound"},"content":{"rendered":"<p><strong>Tinkercad Video:<\/strong><\/p>\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-12520-1\" width=\"620\" height=\"393\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/tinkercad_vid.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/tinkercad_vid.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/tinkercad_vid.mp4<\/a><\/video><\/div>\n<p>Tinkercad does not have a lot of components that are present in the real life version, so there are some fake data simulation. In real life, our first sensor is an accelerometer, but we simulated it with a potentiometer. The values are mapped to be in between 0-100 to mimic values we could get from our accelerometer. From there, the data is mapped to a value between 130-180 so serve as an angle for the servo motor. In real life, the servo motor would move an object in front of an ultrasonic ranger, but instead, we have to fake the simulation. The distance output from the ultrasonic ranger is then mapped to a value between 100 and 600 to serve as tone for the buzzer.<\/p>\n<p><strong>Photos for Scale:<\/strong><\/p>\n<p>Shuyu:<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-12575\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2215-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2215-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2215-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2215-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2215-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2215-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2215-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2215-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>Vishnu:<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-12529\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-9.14.08-PM.jpg\" alt=\"\" width=\"241\" height=\"337\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-9.14.08-PM.jpg 241w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-9.14.08-PM-215x300.jpg 215w\" sizes=\"(max-width: 241px) 100vw, 241px\" \/><\/p>\n<p><strong>Detail Photos<\/strong><\/p>\n<div id=\"attachment_12554\" style=\"width: 1180px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12554\" loading=\"lazy\" class=\"size-full wp-image-12554\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2214-1.jpg\" alt=\"\" width=\"1170\" height=\"1560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2214-1.jpg 1170w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2214-1-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2214-1-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2214-1-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2214-1-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2214-1-508x677.jpg 508w\" sizes=\"(max-width: 1170px) 100vw, 1170px\" \/><p id=\"caption-attachment-12554\" class=\"wp-caption-text\">Initially, getting data from the accelerometer was a little foreign, so it took some thinking on how we would utilize the data.<\/p><\/div>\n<div id=\"attachment_12555\" style=\"width: 1180px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12555\" loading=\"lazy\" class=\"size-full wp-image-12555\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2213-1.jpg\" alt=\"\" width=\"1170\" height=\"1560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2213-1.jpg 1170w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2213-1-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2213-1-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2213-1-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2213-1-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2213-1-508x677.jpg 508w\" sizes=\"(max-width: 1170px) 100vw, 1170px\" \/><p id=\"caption-attachment-12555\" class=\"wp-caption-text\">The accelerometer was a new tool to us, so we had to research on how to wire and write code for it.<\/p><\/div>\n<div id=\"attachment_12556\" style=\"width: 1180px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12556\" loading=\"lazy\" class=\"size-full wp-image-12556\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2212-1.jpg\" alt=\"\" width=\"1170\" height=\"2532\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2212-1.jpg 1170w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2212-1-139x300.jpg 139w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2212-1-473x1024.jpg 473w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2212-1-768x1662.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2212-1-710x1536.jpg 710w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2212-1-946x2048.jpg 946w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2212-1-973x2106.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2212-1-508x1099.jpg 508w\" sizes=\"(max-width: 1170px) 100vw, 1170px\" \/><p id=\"caption-attachment-12556\" class=\"wp-caption-text\">Testing everything with a pancake motor at the end.<\/p><\/div>\n<div id=\"attachment_12557\" style=\"width: 2044px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12557\" loading=\"lazy\" class=\"size-full wp-image-12557\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2211-1.jpg\" alt=\"\" width=\"2034\" height=\"1170\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2211-1.jpg 2034w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2211-1-300x173.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2211-1-1024x589.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2211-1-768x442.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2211-1-1536x884.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2211-1-973x560.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2211-1-508x292.jpg 508w\" sizes=\"(max-width: 2034px) 100vw, 2034px\" \/><p id=\"caption-attachment-12557\" class=\"wp-caption-text\">Building the arm that extend back and forth had its mechanical difficulties. It took a while to troubleshoot how far the arm could extend.<\/p><\/div>\n<p><strong>Videos:<\/strong><\/p>\n<p>Shuyu:<\/p>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12520-2\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2218-1.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2218-1.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2218-1.mp4<\/a><\/video><\/div>\n<p>&nbsp;<\/p>\n<p>Vishnu:<\/p>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12520-3\" width=\"620\" height=\"1102\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/device_vid-1.mp4?_=3\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/device_vid-1.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/device_vid-1.mp4<\/a><\/video><\/div>\n<p>&nbsp;<\/p>\n<p><strong>Narrative Description:<\/strong><\/p>\n<p><span style=\"font-weight: 400\">Our double transducer takes in vibration as an input (via a 3-axis accelerometer), and converts that input to an angle for a servo motor. The servo motor is attached to a popsicle stick \u201carm\u201d that extends based on the angle. An ultrasonic ranger detects how far the popsicle sticks are from it and the resulting distance (cm) is converted into a tone for an 8-ohm speaker.\u00a0<\/span><\/p>\n<p><strong>Progress Photos:<\/strong><\/p>\n<div id=\"attachment_12549\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12549\" loading=\"lazy\" class=\"size-full wp-image-12549\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2194_1-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2194_1-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2194_1-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2194_1-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2194_1-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2194_1-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2194_1-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2194_1-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-12549\" class=\"wp-caption-text\">Shuyu: This was when I first successfully wired and ran some code through the LCD display. It was super exciting because the wiring was a little intense and something could have easily gone wrong.<\/p><\/div>\n<div id=\"attachment_12548\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12548\" loading=\"lazy\" class=\"size-full wp-image-12548\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2190_1-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2190_1-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2190_1-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2190_1-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2190_1-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2190_1-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2190_1-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2190_1-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2190_1-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-12548\" class=\"wp-caption-text\">Shuyu: Using a transistor to wire a speaker was a new concept and wiring it correctly was a major step in the overall project.<\/p><\/div>\n<div id=\"attachment_12611\" style=\"width: 1180px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12611\" loading=\"lazy\" class=\"size-full wp-image-12611\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2219.jpg\" alt=\"\" width=\"1170\" height=\"1560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2219.jpg 1170w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2219-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2219-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2219-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2219-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2219-508x677.jpg 508w\" sizes=\"(max-width: 1170px) 100vw, 1170px\" \/><p id=\"caption-attachment-12611\" class=\"wp-caption-text\">Vishnu: Troubleshooting the popsicle arm and trying to find a good angle range. I ended up building barriers for it.<\/p><\/div>\n<div id=\"attachment_12612\" style=\"width: 1180px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12612\" loading=\"lazy\" class=\"size-full wp-image-12612\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2220.jpg\" alt=\"\" width=\"1170\" height=\"1560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2220.jpg 1170w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2220-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2220-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2220-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2220-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_2220-508x677.jpg 508w\" sizes=\"(max-width: 1170px) 100vw, 1170px\" \/><p id=\"caption-attachment-12612\" class=\"wp-caption-text\">Vishnu: Wiring the speaker had some challenges because wires were not connected into the right ports.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p><strong>Discussion:<\/strong><\/p>\n<p><span style=\"font-weight: 400\">The entire process of brainstorming, planning, and creating the double transducer was filled with its unique set of problems and triumphs. From the beginning, we were not familiar with vibration as an input and we were not sure how ambitious we should be with our middle step.\u00a0<\/span><span style=\"font-weight: 400\">We played around with a couple of ideas, including a basic vibration to light to sound workflow. Excluding the vibration portion, we were confident we could get the \u201clight\u201d middle step (LED + photoresistor) to work and output sound; this would serve as a good backup plan in case a more ambitious setup failed.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The ambitious idea we settled on was a system of vibration to movement to sound. We decided to split the \u201cmovement\u201d into two parts: One part performing the movement (a Servo motor with a lever attached), and the other part sensing proximity and outputting a distance value (via an ultrasonic ranger). We found that while the idea was simple enough, the middle step ran into significant challenges.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Most notably, we had to restrict the servo motor from its total range, in order to constrain it to the board as well as prevent it from ripping out of its supports. This was mainly achieved through trial and error, and each of us had slightly different ranges based on the physical layout of our board and device.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">With help from Zach, we realized that a good stand-in for a vibration sensor was a 3-axis accelerometer. The accelerometer senses the position (X,Y, Z) of the device if it is even slightly shifted. We realized that this could work to our advantage, although we needed to manually manipulate it to achieve the output. We found that because we had to twist the accelerometer around, we had to make sure to bolt the apparatus down through soldering and tape.<\/span><\/p>\n<p><span style=\"font-weight: 400\">This project definitely pushed us to understand the real-world limitations of theoretical concepts. While there were chunks of the project we could neatly resolve in software, there were other parts we simply had to stress-test through empirical trials (such as the servo extension). Overall, we came away with a solid understanding of the relationship between different mediums, as well as the interlocking nature of software and hardware in electronics.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Functional Block Diagram:<\/strong><\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-12567 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/block.png\" alt=\"\" width=\"908\" height=\"292\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/block.png 908w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/block-300x96.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/block-768x247.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/block-508x163.png 508w\" sizes=\"(max-width: 908px) 100vw, 908px\" \/><\/p>\n<p><strong> Schematic:<\/strong><\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-12566 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/schem-1.png\" alt=\"\" width=\"611\" height=\"472\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/schem-1.png 611w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/schem-1-300x232.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/schem-1-508x392.png 508w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/*\r\n   60-223, Double Transducer : Vibration to Movement to Sound\r\n   Shuyu Zhang, Vishnu Raghavan\r\n\r\n   Description: Our doubel transducer takes in vibration as an input.\r\n   The input is measured by a 3-axis accelerometer. The difference between\r\n   the input from the x-axis and y-axis is then mapped to an angle\r\n   for a servo motor (130-180 degrees). In real life, the servo motor is\r\n   attached to a popsicle arm that will extend based on the angle the servo\r\n   motor moves to. An ultrasonic ranger sits in front of the popsicle arm\r\n   and measures how close or far the arm is from it. The data from the\r\n   ultrasonic ranger is then mapped to a tone (100-600) which is the output\r\n   for a speaker.\r\n\r\n   Sources:\r\n   1) Heavily referenced the program on the maker cards website when programming the\r\n   accelerometer\r\n   2) Incorporated some of the code of an example from the HCSR04 library in order\r\n   to read distance with the ultrasonic ranger\r\n   3) Referenced the Servo Motor example from class to program the servo motor\r\n   4) Used LCD Display wiring and program from Arudino Website to program the\r\n   LCD Display\r\n\r\n\r\n   Pin mapping:\r\n\r\n   Arduino pin | type   | description\r\n   ------------|--------|-------------\r\n   12     LCD Pin  Used to initialize the LiquidCrystal Library\r\n   11     LCD Pin  Used to initialize the LiquidCrystal Library\r\n   5      LCD Pin  Used to initialize the LiquidCrystal Library\r\n   4      LCD Pin  Used to initialize the LiquidCrystal Library\r\n   3      LCD Pin  Used to initialize the LiquidCrystal Library\r\n   2      LCD Pin  Used to initialize the LiquidCrystal Library\r\n   9      Output   Servo Motor pin\r\n   6      Output   Buzzer pin\r\n   13     Input    Trigger Pin in the Ultrasonic ranger\r\n   7      Input    Echo Pin in the Unltrasonic ranger\r\n   A0     Input    Analog input pin for X movement\r\n   A1     Input .  Analog input pin for Y movement\r\n   A2     Input    Analog input pin for Z movement\r\n\r\n*\/\r\n\r\n#include &lt;HCSR04.h&gt;\r\n#include &lt;Servo.h&gt;\r\n#include &lt;LiquidCrystal.h&gt;\r\n\r\nconst int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;\r\nLiquidCrystal lcd(rs, en, d4, d5, d6, d7);\r\n\r\nServo motor;\r\nbyte triggerPin = 13;\r\nbyte echoPin = 7;\r\nconst int SERVOPIN = 9; \/\/Analog\r\nconst int BUZZER = 6; \/\/Analog output in for 8\u03a9 Speaker\r\nconst int ACCELXPIN = A0; \/\/ Analog input pin for X movement\r\nconst int ACCELYPIN = A1; \/\/ Analog input pin for Y movement\r\nconst int ACCELZPIN = A2; \/\/ Analog input pin for Z movement\r\nconst int TIMERWAIT = 1000;\r\nconst int MOTORWAIT = 200;\r\n\r\n\/\/ Variables to keep track of the current positions\r\nint accelXPos = 0;\r\nint accelYPos = 0;\r\nint accelZPos = 0;\r\nint dist;\r\nint angle;\r\nint currTone;\r\nint accelData;\r\nunsigned long timer = 0;\r\nunsigned long motorTimer = 0;\r\n\r\nvoid setup() {\r\n  Serial.begin(9600);\r\n\r\n  \/\/Set up for ultrasonic ranger\r\n  HCSR04.begin(triggerPin, echoPin);\r\n\r\n  \/\/Set up for servo motor\r\n  motor.attach(SERVOPIN);\r\n\r\n  \/\/ Setup the accelerometer inputs\r\n  pinMode(ACCELXPIN, INPUT);\r\n  pinMode(ACCELYPIN, INPUT);\r\n  pinMode(ACCELZPIN, INPUT);\r\n\r\n  \/\/Setup for buzzer output\r\n  pinMode(BUZZER, OUTPUT);\r\n\r\n  \/\/ set up the LCD's number of columns and rows:\r\n  lcd.begin(16, 2);\r\n \r\n}\r\n\r\nvoid loop() {\r\n\r\n  \/\/ Get the current states\r\n  accelXPos = analogRead(ACCELXPIN);\r\n  accelYPos = analogRead(ACCELYPIN);\r\n  accelZPos = analogRead(ACCELZPIN);\r\n\r\n  \/\/declares a variable to read distance for ultrasonic ranger\r\n  double* distances = HCSR04.measureDistanceCm();\r\n\r\n  accelData = abs(accelXPos - accelYPos); \/\/Gives range of (0-90)\r\n\r\n  \/\/Mapping Accelerometer data to an angle\r\n  angle = map(accelData, 0, 90, 130, 180);\r\n\r\n\r\n  \/\/Set at a delay of 200 milliseconds\r\n  \/\/c\r\n  if (millis() - motorTimer &gt; MOTORWAIT) {\r\n    motorTimer = millis();\r\n\r\n    dist = (int)(distances[0]);\r\n    currTone = map(dist, 0, 30, 100, 600);\r\n    tone(BUZZER, currTone);\r\n\r\n    \/\/changes angle based on accelerometer input\r\n    \/\/changes tone based on distance\r\n    motor.write(angle);\r\n    delay(200);\r\n    tone(BUZZER, currTone);\r\n    motor.write(angle);\r\n    delay(200);\r\n\r\n  }\r\n\r\n\r\n  \/\/LCD Display Code\r\n  if (millis() - timer &gt; TIMERWAIT) {\r\n    timer = millis();\r\n\r\n    lcd.setCursor(8, 1);\r\n    int midSen = map(dist, 0, 30, 0, 99);\r\n    lcd.print(midSen);\r\n    if (midSen &gt; 100) {\r\n      lcd.clear();\r\n    }\r\n\r\n    \/\/First Row on LCD\r\n    lcd.setCursor(0, 0);\r\n    lcd.print(\"i:\");\r\n    int input = map(accelData, 0, 90, 0, 99);\r\n    lcd.print(input);\r\n    lcd.setCursor(7, 0);\r\n    lcd.print(\"m:\");\r\n    int midAct = map(angle, 130, 180, 0, 99);\r\n    lcd.print(midAct);\r\n\r\n    \/\/Second Row on LCD\r\n    lcd.setCursor(12, 1);\r\n    lcd.print(\"o:\");\r\n    int output = map(currTone, 200, 600, 0, 99);\r\n    lcd.print(output);\r\n  }\r\n\r\n\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tinkercad Video: Tinkercad does not have a lot of components that are present in the real life version, so there are some fake data simulation. In real life,&#8230;<\/p>\n","protected":false},"author":181,"featured_media":12578,"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\/s2021\/work\/wp-json\/wp\/v2\/posts\/12520"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/users\/181"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/comments?post=12520"}],"version-history":[{"count":26,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/12520\/revisions"}],"predecessor-version":[{"id":12615,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/12520\/revisions\/12615"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media\/12578"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media?parent=12520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/categories?post=12520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/tags?post=12520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}