{"id":12348,"date":"2021-03-08T20:13:27","date_gmt":"2021-03-09T01:13:27","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/?p=12348"},"modified":"2021-03-10T09:37:35","modified_gmt":"2021-03-10T14:37:35","slug":"double-transducer-ultrasonic-to-rotation-to-light-output","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/double-transducer-ultrasonic-to-rotation-to-light-output\/","title":{"rendered":"Double Transducer: Ultrasonic to Rotation to Light Output"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignnone size-large wp-image-12360\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1349-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1349-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1349-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1349-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1349-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1349-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1349-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1349-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/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-12348-1\" 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\/part-1.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/part-1.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/part-1.mp4<\/a><\/video><\/div>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12348-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\/part-2.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/part-2.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/part-2.mp4<\/a><\/video><\/div>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12348-3\" 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\/trimmed-chain.mp4?_=3\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/trimmed-chain.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/trimmed-chain.mp4<\/a><\/video><\/div>\n<h3>Initial Sketches and Block Diagram:<\/h3>\n<p><img loading=\"lazy\" class=\"alignnone size-large wp-image-12363\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Arduino-Transducer-sketches-1024x723.jpg\" alt=\"\" width=\"620\" height=\"438\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Arduino-Transducer-sketches-1024x723.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Arduino-Transducer-sketches-300x212.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Arduino-Transducer-sketches-768x543.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Arduino-Transducer-sketches-1536x1085.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Arduino-Transducer-sketches-973x687.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Arduino-Transducer-sketches-508x359.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Arduino-Transducer-sketches.jpg 1754w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/> <img loading=\"lazy\" class=\"alignnone size-large wp-image-12364\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Ideas-Angle-856x1024.jpg\" alt=\"\" width=\"620\" height=\"742\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Ideas-Angle-856x1024.jpg 856w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Ideas-Angle-251x300.jpg 251w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Ideas-Angle-768x919.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Ideas-Angle-973x1164.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Ideas-Angle-508x608.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Ideas-Angle.jpg 976w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>For the middle step on our transducer, we were deciding between having a servo drive a potentiometer, having a servo drive a platform with an accelerometer, and having a speaker output measured by a microphone. We ended up deciding on the servo &#8211; accelerometer pair, but also made a servo &#8211; potentiometer prototype as an initial version to test various components on.<\/p>\n<h3>TinkerCAD Exploration<\/h3>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12348-4\" width=\"620\" height=\"1123\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Untitled-2.mp4?_=4\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Untitled-2.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Untitled-2.mp4<\/a><\/video><\/div>\n<h3>Ultrasonic to Potentiometer to LED<\/h3>\n<h4>Erica&#8217;s Version<\/h4>\n<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-12388\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-08-at-8.28.17-PM-255x300.jpg\" alt=\"\" width=\"255\" height=\"300\" \/><\/p>\n<p>This was the initial double transducer design we had. My project was barely held together. I had to tape the micro servo to the Maker Cards and used the wire cutter to hold the breadboard down so that the board wouldn\u2019t lift when the servo motor turned the potentiometer.<\/p>\n<p>Using an ultrasonic ranger, I detected the distance from the build. The ranger determined the angle of the servo motor which was attached to the potentiometer. This potentiometer then determined the brightness of the LED.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-12382\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1907-225x300.jpeg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1907-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1907-768x1024.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1907-1152x1536.jpeg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1907-1536x2048.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1907-973x1297.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1907-508x677.jpeg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1907-scaled.jpeg 1920w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/><\/p>\n<p>By replacing the small breadboard with a bigger version, I was able to make a less cluttered double transducer.<\/p>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12348-5\" 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\/Untitled-1.mp4?_=5\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Untitled-1.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Untitled-1.mp4<\/a><\/video><\/div>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12348-6\" 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\/Untitled.mp4?_=6\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Untitled.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Untitled.mp4<\/a><\/video><\/div>\n<p>Here is a video of my working double transducer. I displayed the input and output values using the Serial Monitor on Arduino. Through the video, you can see that the light turns brighter when the box is closer to the ultrasonic sensor and dimmer when the box is further away.<\/p>\n<h4>Eric&#8217;s Version<\/h4>\n<p><img loading=\"lazy\" class=\"alignnone size-large wp-image-12358\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/first-transducer-1024x571.jpg\" alt=\"\" width=\"620\" height=\"346\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/first-transducer-1024x571.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/first-transducer-300x167.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/first-transducer-768x428.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/first-transducer-1536x856.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/first-transducer-973x542.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/first-transducer-508x283.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/first-transducer.jpg 1914w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>Similar to Erica&#8217;s version, I connected the servo to the potentiometer through a paperclip and servo mount.<\/p>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12348-7\" 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_1332.mp4?_=7\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1332.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1332.mp4<\/a><\/video><\/div>\n<p>Due to the noisiness of the ultrasonic data, I added a moving average filter to smooth that out. Also, I found out the analog input pins do not have PWM capabilities which was a helpful reference for later.<\/p>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12348-8\" 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\/LED-woes.mp4?_=8\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/LED-woes.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/LED-woes.mp4<\/a><\/video><\/div>\n<p>&nbsp;<\/p>\n<h3>Ultrasonic to Accelerometer to LED<\/h3>\n<h4>Erica&#8217;s Contribution<\/h4>\n<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-12391\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1795-1-225x300.jpeg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1795-1-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1795-1-768x1024.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1795-1-1152x1536.jpeg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1795-1-1536x2048.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1795-1-973x1297.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1795-1-508x677.jpeg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1795-1-scaled.jpeg 1920w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/><\/p>\n<p>We soldered the 3-axis accelerometer and a terminal, ensuring a strong connection for our middle step in the transducer. The final configuration of the objects on the board was tightly put together, with the 3-axis accelerometer acting like a protective hood over the terminal.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-12392\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/63647347491__5A056774-A0B8-492F-BFBD-AC3B9B9487A3-1-225x300.jpeg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/63647347491__5A056774-A0B8-492F-BFBD-AC3B9B9487A3-1-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/63647347491__5A056774-A0B8-492F-BFBD-AC3B9B9487A3-1-768x1024.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/63647347491__5A056774-A0B8-492F-BFBD-AC3B9B9487A3-1-1152x1536.jpeg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/63647347491__5A056774-A0B8-492F-BFBD-AC3B9B9487A3-1-1536x2048.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/63647347491__5A056774-A0B8-492F-BFBD-AC3B9B9487A3-1-973x1297.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/63647347491__5A056774-A0B8-492F-BFBD-AC3B9B9487A3-1-508x677.jpeg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/63647347491__5A056774-A0B8-492F-BFBD-AC3B9B9487A3-1-scaled.jpeg 1920w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/><\/p>\n<p>For the final project, I also configured the LCD to display the outputs. Working with the LCD was difficult because of the intense amount of wiring, but through following tutorials online, I was able to successfully have the LCD display our input and output values.<\/p>\n<h4>Eric&#8217;s Contribution<img loading=\"lazy\" class=\"alignnone size-large wp-image-12359\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/how-to-get-accelerometer-position-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/how-to-get-accelerometer-position-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/how-to-get-accelerometer-position-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/how-to-get-accelerometer-position-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/how-to-get-accelerometer-position-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/how-to-get-accelerometer-position-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/how-to-get-accelerometer-position-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/how-to-get-accelerometer-position-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/h4>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12348-9\" 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\/accelerometer-test.mp4?_=9\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/accelerometer-test.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/accelerometer-test.mp4<\/a><\/video><\/div>\n<p>To convert the accelerometer&#8217;s 3-axis acceleration readings into an angle value that could be interpreted as a parallel to the servo&#8217;s rotation, there was a little trig involved (taking an inverse tangent of two axes, modeled after the unit circle). The above clip is me testing the accelerometer&#8217;s analog inputs and figuring out the range of raw inputs to map to -1 and 1 for both x and y values on the unit circle.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-large wp-image-12378\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1794-1-768x1024.jpeg\" alt=\"\" width=\"620\" height=\"827\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1794-1-768x1024.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1794-1-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1794-1-1152x1536.jpeg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1794-1-1536x2048.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1794-1-973x1297.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1794-1-508x677.jpeg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1794-1-scaled.jpeg 1920w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>For the final transducer, I soldered part of the proto-board that the accelerometer attaches to and mounted the the board onto the servo arm via paper clips.<\/p>\n<h3>Detail Shots of Final Project<\/h3>\n<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-12677\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1916-225x300.jpeg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1916-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1916-768x1024.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1916-1152x1536.jpeg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1916-1536x2048.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1916-973x1297.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1916-508x677.jpeg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1916-scaled.jpeg 1920w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/> <img loading=\"lazy\" class=\"alignnone size-medium wp-image-12678\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1917-225x300.jpeg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1917-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1917-768x1024.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1917-1152x1536.jpeg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1917-1536x2048.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1917-973x1297.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1917-508x677.jpeg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1917-scaled.jpeg 1920w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/> <img loading=\"lazy\" class=\"alignnone size-medium wp-image-12679\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1918-225x300.jpeg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1918-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1918-768x1024.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1918-1152x1536.jpeg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1918-1536x2048.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1918-973x1297.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1918-508x677.jpeg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1918-scaled.jpeg 1920w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/><img loading=\"lazy\" class=\"alignnone size-large wp-image-12681\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1366-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1366-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1366-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1366-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1366-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1366-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1366-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1366-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<h3>Code<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/*\r\n * 60-223, Project 1\r\n * Eric Zhao (ezhao2), Erica Fu (efu)\r\n * time spent: 20 hours \r\n *\r\n * Collaboration and sources: \r\n * 1) Eric and Erica worked together from planning, coding, to building the final project\r\n * 2) Zach assisted many times throughout the process\r\n * 3) We borrowed heavily from the Arduino guide to use the LiquidCrystal library\r\n * website link: https:\/\/www.arduino.cc\/en\/Tutorial\/LibraryExamples\/HelloWorld\r\n * 4) We implemented this moving average filter to smooth out ultrasonic data values:\r\n * https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/tutorials\/code-bites#exponential-moving-average-filter\r\n * Challenge(s): Since there are many wires, the wiring often became jumbled and confusing. \r\n * Also, the LCD display could only use certain pins, causing us to have to rewire the whole project.\r\n * The connection from the servo motor to the 3-axis-accelerometer was also quite difficult since\r\n * we had to customize parts and eventually settle for using a paperclip to make a mechanical connection.\r\n * \r\n * Next time: We will organize wiring better so that the circut is clearer so that any change \r\n * of wiring will be less confusing.\r\n *To prevent breaking any more Arduinos, Erica will double check the wiring to ensure that \r\n * there is minimal damage caused in the future.\r\n * \r\n * Description: The entire breadboard is mounted to a servo motor whose output shaft is connected to a \r\n * rigid vertical structure. Depending on the input voltage from the ultrasonic sensor, the servo motor \r\n * will output a corresponding angle, causing the entire breadboard to rotate. An accelerometer attached \r\n * to the breadboard will read the tilt angle of the breadboard caused by the servo. The input voltage \r\n * will determine the output voltage of the LED.\r\n * \r\n * Pin mapping:\r\n * \r\n * Arduino pin | type   | description\r\n * ------------|--------|-------------\r\n * A0            input     xInput of the 3-axis accelerometer\r\n * A1            input     yInput of the 3-axis accelerometer\r\n * A2            input     zInput of the 3-axis accelerometer\r\n * 9             output    mini servo motor\r\n * 6             output    red LED \r\n * 12            output    rs pin for the LCD monitor\r\n * 11            output    en pin for the LCD monitor\r\n * 5             output    d4 pin for the LCD monitor\r\n * 4             output    d5 pin for the LCD monitor\r\n * 3             output    d6 pin for the LCD monitor\r\n * 2             output    d7 pin for the LCD monitor\r\n * \r\n *\/\r\n \r\n#include &lt;Servo.h&gt;\r\n#include &lt;NewPing.h&gt;\r\n#include &lt;LiquidCrystal.h&gt;\r\n\r\n#define TRIGGER_PIN 8\r\n#define ECHO_PIN 7\r\n#define MAX_DISTANCE 75\r\n\r\nNewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);\r\n\r\nconst int waitTime = 250;\r\nlong prevTime = 0;\r\n\r\nconst int xInput = A0;\r\nconst int yInput = A1;\r\nconst int zInput = A2;\r\nconst int SERVOPIN = 9;\r\nconst int LED = 6;\r\nServo SERVO;\r\n\r\nfloat filtered_val = 0;  \/\/ this variable, of type float (decimal), holds the filtered sensor value\r\nconst float PREV_WEIGHT = 0.8; \/\/ this variable, of type float (decimal), determines the previously filtered value's weight.\r\nconst float CUR_WEIGHT = 1 - PREV_WEIGHT; \/\/ this variable, of type float (decimal), determines the current sample's weight.\r\nconst int SENSOR_PIN = A0; \/\/ this variable, of type int, determines the sensor's pin.\r\n\r\n\/\/ initialize the library by associating any needed LCD interface pin\r\n\/\/ with the arduino pin number it is connected to\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\nvoid setup() {\r\n  \/\/ put your setup code here, to run once:\r\n  pinMode(xInput, INPUT);\r\n  pinMode(yInput, INPUT);\r\n  pinMode(zInput, INPUT);\r\n  pinMode(LED, OUTPUT);\r\n  SERVO.attach(SERVOPIN);\r\n  Serial.begin(115200);\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\nvoid loop() {\r\n  \/\/ put your main code here, to run repeatedly:\r\n  \r\n  delay(50);\r\n  \/\/raw data by axis from accelerometer\r\n  int x = analogRead(xInput);\r\n  int y = analogRead(yInput);\r\n  int z = analogRead(zInput);\r\n  \/\/data from accelerometer, mapped to units -1000 to 1000\r\n  int xVect = map(x, 260, 390, -1000, 1000);\r\n  int yVect = map(y, 250, 380, -1000, 1000);\r\n  int zVect = map(z, 320, 385, 0, 1000);\r\n  \/\/below variables are the above vars but divided by 1000 to achieve unit circle\r\n  float xVectUnbound = xVect\/1000.0;  \r\n  float yVectUnbound = yVect\/1000.0;\r\n  float zVectUnbound = zVect\/1000.0;\r\n  \/\/constraining final readings to unit circle -1 to 1\r\n  float xVectFinal = constrain(xVectUnbound, -1, 1); \r\n  float yVectFinal = constrain(yVectUnbound, -1, 1);\r\n  float zVectFinal = constrain(zVectUnbound, 0, 1);\r\n  \/\/final arctan value (takes two axes and converts into degrees)\r\n  float degreeVal = atan2(xVectFinal, zVectFinal) * 180\/PI;\r\n\r\n  \/\/creates a weighted reading\r\n  float cur_reading = sonar.ping_cm();\r\n  if(cur_reading != 0){\r\n    filtered_val = filtered_val * PREV_WEIGHT + cur_reading * CUR_WEIGHT;\r\n  }\r\n\r\n  \/\/takes a smoothed out sonar reading and converts to servo degrees\r\n  int servoVal = map(filtered_val, 0, 75, 0, 180);\r\n  \/\/takes accelerometer degree reading and converts to\r\n  int outputVal = map(degreeVal, -55, 90, 0, 255);\r\n  if(cur_reading != 0 &amp;&amp; servoVal &gt; 0){\r\n    SERVO.write(servoVal);\r\n  }\r\n  \r\n  if(outputVal &gt; 0){\r\n    analogWrite(LED, outputVal);\r\n  }\r\n\r\n  int inputDisplay = map(filtered_val, 0, 75, 0, 100);\r\n  int middleActDisplay = map(servoVal, 0, 180, 0, 100);\r\n  int middleSensorDisplay = map(outputVal, 0, 255, 0, 100);\r\n\r\n  if(millis() - prevTime &gt; waitTime){\r\n    \/\/outputs data to LCD display 4 times a second\r\n    lcd.setCursor(0,0);\r\n    lcd.print((String)\"i:\"+ inputDisplay);\r\n    lcd.setCursor(5,0);\r\n    lcd.print((String)\"m:\" + middleActDisplay);\r\n    lcd.setCursor(7,1);\r\n    lcd.print(middleSensorDisplay);\r\n    lcd.setCursor(11,1);\r\n    lcd.print((String)\"o:\" + middleSensorDisplay);\r\n\r\n    prevTime = millis();\r\n  }\r\n\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h3>Reflection<\/h3>\n<p>We found a lot more issues throughout the span of this project than either of us imagined would happen! Different libraries conflicted with each other (for example, the Servo library shut down certain pins that the NewPing ultrasonic library utilized). Mechanical connections between certain parts were difficult to make robust enough to handle the servo\u2019s torque; we ended up using paperclips for a lot of these as compared to tape, which was a lot weaker.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Initial Sketches and Block Diagram: For the middle step on our transducer, we were deciding between having a servo drive a potentiometer, having a servo drive a platform&#8230;<\/p>\n","protected":false},"author":175,"featured_media":12360,"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\/12348"}],"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\/175"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/comments?post=12348"}],"version-history":[{"count":15,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/12348\/revisions"}],"predecessor-version":[{"id":12691,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/12348\/revisions\/12691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media\/12360"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media?parent=12348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/categories?post=12348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/tags?post=12348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}