{"id":15081,"date":"2022-02-15T19:39:17","date_gmt":"2022-02-16T00:39:17","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/?p=15081"},"modified":"2022-02-16T10:00:19","modified_gmt":"2022-02-16T15:00:19","slug":"double-transducer-tapping-rate-to-vertical-distance","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/double-transducer-tapping-rate-to-vertical-distance\/","title":{"rendered":"Double Transducer: Tapping Rate to Vertical Distance"},"content":{"rendered":"<p>&nbsp;<\/p>\n<div id=\"attachment_15089\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15089\" loading=\"lazy\" class=\"wp-image-15089 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Lynn-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1707\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Lynn-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Lynn-300x200.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Lynn-1024x683.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Lynn-768x512.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Lynn-1536x1024.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Lynn-2048x1365.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Lynn-973x649.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Lynn-508x339.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15089\" class=\"wp-caption-text\">Overall photo of Lynn&#8217;s double transducer<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15095\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15095\" loading=\"lazy\" class=\"wp-image-15095 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Yongwen-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1707\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Yongwen-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Yongwen-300x200.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Yongwen-1024x683.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Yongwen-768x512.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Yongwen-1536x1024.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Yongwen-2048x1365.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Yongwen-973x649.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Overall-Photo-for-Yongwen-508x339.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15095\" class=\"wp-caption-text\">Overall photo of Yongwen&#8217;s double transducer<\/p><\/div>\n<p>&nbsp;<\/p>\n<h3><b>Detail Photos:<\/b><\/h3>\n<div id=\"attachment_15091\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15091\" loading=\"lazy\" class=\"wp-image-15091 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Input-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1707\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Input-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Input-300x200.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Input-1024x683.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Input-768x512.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Input-1536x1024.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Input-2048x1365.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Input-973x649.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Input-508x339.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15091\" class=\"wp-caption-text\">The lever switch connects to the first breadboard (the knight is trying to save the princess by tapping the switch)<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15090\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15090\" loading=\"lazy\" class=\"wp-image-15090 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Wiring-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1707\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Wiring-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Wiring-300x200.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Wiring-1024x683.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Wiring-768x512.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Wiring-1536x1024.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Wiring-2048x1365.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Wiring-973x649.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Wiring-508x339.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15090\" class=\"wp-caption-text\">Wiring details<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15096\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15096\" loading=\"lazy\" class=\"wp-image-15096 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Soldering-Connection-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1707\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Soldering-Connection-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Soldering-Connection-300x200.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Soldering-Connection-1024x683.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Soldering-Connection-768x512.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Soldering-Connection-1536x1024.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Soldering-Connection-2048x1365.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Soldering-Connection-973x649.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Soldering-Connection-508x339.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15096\" class=\"wp-caption-text\">The photoresistor detects the LED brightness<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15093\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15093\" loading=\"lazy\" class=\"wp-image-15093 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-Breadborad-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1707\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-Breadborad-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-Breadborad-300x200.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-Breadborad-1024x683.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-Breadborad-768x512.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-Breadborad-1536x1024.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-Breadborad-2048x1365.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-Breadborad-973x649.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-Breadborad-508x339.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15093\" class=\"wp-caption-text\">The second breadboard assembles the last wires to connect to the servo motor<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15092\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15092\" loading=\"lazy\" class=\"wp-image-15092 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-saving-princess-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1707\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-saving-princess-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-saving-princess-300x200.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-saving-princess-1024x683.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-saving-princess-768x512.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-saving-princess-1536x1024.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-saving-princess-2048x1365.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-saving-princess-973x649.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Output-saving-princess-508x339.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15092\" class=\"wp-caption-text\">The arm is connected to the servo motor which can lift the platform up from 1 inch to 4 inches (the princess is being attacked by the dragon, please save her!)<\/p><\/div>\n<h3>Videos:<\/h3>\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-15081-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\/LYNN.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/LYNN.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/LYNN.mp4<\/a><\/video><\/div>\n<p>Video demonstration of Lynn&#8217;s double transducer.<\/p>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-15081-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\/YONGWEN.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/YONGWEN.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/YONGWEN.mp4<\/a><\/video><\/div>\n<p>Video demonstration of Yongwen&#8217;s double transducer.<\/p>\n<h3>Narrative Description:<\/h3>\n<p><span style=\"font-weight: 400\">Our double transducer takes the tapping rate on the lever of the lever microswitch as an input. The speed of tapping on the lever translates to the brightness of the LED. The LED brightness is read by the photoresistor and dictates the position of a servo motor arm which lifts a princess cut-out up and down. An LCD screen will read out the tapping rate, LED brightness, photoresistor reading, and hobby servo motor arm position.\u00a0<\/span><\/p>\n<h3><b>Discussion:<\/b><\/h3>\n<p><span style=\"font-weight: 400\">Overall, this project presented a valuable opportunity for us to become more familiar with coding in C and learn the electrical workings of different sensors and actuators. Both of us came in with different skill sets. Yongwen provided many creative ideas, such as turning our double transducer into a game of sorts where a princess was tied to the lifting arm of the servo motor and trying to escape a dragon cut-out at the bottom of the platform. She also provided insight into the most visually appealing layout of our final project. Lynn came in with some coding experience in python, so she was able to take a larger role in debugging our code when we were not getting the LCD readings or outputs we expected. By th<\/span>e time we completed the final product, we had both picked up on many new skills from each other.<\/p>\n<p><span style=\"font-weight: 400\">Although we ran into challenges with almost every step of this project, this allowed us to learn a lot about the wiring and coding required to operate complex electrical circuits and devices. Working with the lever microswitch was one of the most challenging parts. One of the first decisions we had to make was how to perform our tapping rate calculations. Initially, we tried tracking the tapping rate as the number of taps each second but soon realized that we wanted the tapping rate to update faster than each second. Moving forward, we chose to track the tapping rate by measuring the time between taps so that the rate could update after each tap. We also ran into issues of our code outputting higher tapping rate readings than expected. After debugging, we realized that our code was considering each time the switch was in the &#8220;on&#8221; position as a tap. This meant that if the switch was held down for longer, a single long tap was read as multiple tapping events. We solved this issue by adding an &#8220;if statement&#8221; to only count a tap when there was a transition from the &#8220;off&#8221; to the &#8220;on&#8221; position. Even after fixing this in our code, we still were getting tapping rate values that were too high. After talking to Professor Zacharias, we learned that our switch could potentially be experiencing input \u201cbouncing,&#8221; which is essentially electrical noise in the device that causes it to bounce between on\/off states when tapped. <\/span><span style=\"font-weight: 400\">We were able to \u201cdebounce\u201d our input with a simple delay of 3 milliseconds after each switch reading to avoid reading the electrical noise. <\/span><span style=\"font-weight: 400\">By taking the time to understand the intricacies of how the lever micro switch operates, we successfully created code that gave an accurate tapping rate reading.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">If we had more time with this project, we would have chosen a more complex middle step over an LED and photoresistor. Since we were confident that we could get the LED output and photoresistor input working within the time frame of this project, we decided to go in that direction and focus our efforts on developing a code to get an accurate tapping rate reading for the lever microswitch and achieving a vertical lift with the angled servo motor arm. Now that we are more experienced in coding, soldering, and wiring, we could experiment with new sensors and actuators such as a magnetometer for magnetic field strength, an RGB sensor for color, or a buzzer to emit different sound pitches.<\/span><\/p>\n<h3>Progress Photos:<\/h3>\n<div id=\"attachment_15109\" style=\"width: 2089px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15109\" loading=\"lazy\" class=\"size-full wp-image-15109\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/tapping-rate-scaled.jpg\" alt=\"\" width=\"2079\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/tapping-rate-scaled.jpg 2079w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/tapping-rate-244x300.jpg 244w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/tapping-rate-832x1024.jpg 832w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/tapping-rate-768x946.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/tapping-rate-1248x1536.jpg 1248w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/tapping-rate-1663x2048.jpg 1663w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/tapping-rate-973x1198.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/tapping-rate-508x625.jpg 508w\" sizes=\"(max-width: 2079px) 100vw, 2079px\" \/><p id=\"caption-attachment-15109\" class=\"wp-caption-text\">Lynn trying to find the best way to count the tapping rate for the input.<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15111\" style=\"width: 2002px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15111\" loading=\"lazy\" class=\"size-full wp-image-15111\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/output2-scaled.jpg\" alt=\"\" width=\"1992\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/output2-scaled.jpg 1992w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/output2-233x300.jpg 233w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/output2-797x1024.jpg 797w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/output2-768x987.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/output2-1195x1536.jpg 1195w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/output2-1593x2048.jpg 1593w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/output2-973x1251.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/output2-508x653.jpg 508w\" sizes=\"(max-width: 1992px) 100vw, 1992px\" \/><p id=\"caption-attachment-15111\" class=\"wp-caption-text\">Measuring the correct distance for servo motor arm height of 1 inch to 4 inches.<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15112\" style=\"width: 1967px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15112\" loading=\"lazy\" class=\"size-full wp-image-15112\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/soldering2-scaled.jpg\" alt=\"\" width=\"1957\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/soldering2-scaled.jpg 1957w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/soldering2-229x300.jpg 229w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/soldering2-783x1024.jpg 783w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/soldering2-768x1004.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/soldering2-1174x1536.jpg 1174w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/soldering2-1566x2048.jpg 1566w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/soldering2-973x1273.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/soldering2-508x664.jpg 508w\" sizes=\"(max-width: 1957px) 100vw, 1957px\" \/><p id=\"caption-attachment-15112\" class=\"wp-caption-text\">Our first attempt at soldering the LED and photoresistor to a breadboard.<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15113\" style=\"width: 1946px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15113\" loading=\"lazy\" class=\"size-full wp-image-15113\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/organization-scaled.jpg\" alt=\"\" width=\"1936\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/organization-scaled.jpg 1936w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/organization-227x300.jpg 227w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/organization-774x1024.jpg 774w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/organization-768x1016.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/organization-1162x1536.jpg 1162w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/organization-1549x2048.jpg 1549w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/organization-973x1287.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/organization-508x672.jpg 508w\" sizes=\"(max-width: 1936px) 100vw, 1936px\" \/><p id=\"caption-attachment-15113\" class=\"wp-caption-text\">Beginning to assemble our double transducer with the LCD display.<\/p><\/div>\n<h3>Block Diagram:<\/h3>\n<p><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Double-Transducer-Ideas-Idea-1-Block-Diagram.drawio.svg\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-15115\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Double-Transducer-Ideas-Idea-1-Block-Diagram.drawio.svg\" alt=\"\" width=\"971\" height=\"392\" \/><\/a><\/p>\n<h3>Electrical Schematic:<\/h3>\n<p><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Double-Transducer-Ideas-Idea-1-Electrical-Diagram.drawio.svg\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-15116\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Double-Transducer-Ideas-Idea-1-Electrical-Diagram.drawio.svg\" alt=\"\" width=\"1021\" height=\"721\" \/><\/a><\/p>\n<h3>Code:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/* 60-223 Double Transducer\r\n    Lynn Rushkin and Yongwen Dai\r\n\r\n    Description: This code takes the tapping rate read by a lever microswitch and maps that to\r\n                 the brightness of an LED. The level of light emitted from the LED is read by a\r\n                 photoresistor which maps that value to the angle of a hobby servo motor arm.\r\n\r\n    Pin mapping:\r\n    Arduino pin | type   | description\r\n    ------------|--------|-------------\r\n    A2            input     Photoresistor that senses LED brightness\r\n    6             input     Micro lever switch that reads on\/off position of the switch\r\n    3             output    LED pin for brightness\r\n    7             output    hobby servo motor for arm movement\r\n\r\n    The following sources were consulted to create our code:\r\n    https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/tutorials\/servo\r\n    https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/tutorials\/I2C-lcd\r\n    https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/tutorials\/debouncing\r\n    https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/tutorials\/button-and-switch\r\n    <blockquote class=\"wp-embedded-content\" data-secret=\"lGxmN18cUk\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/double-transducer-frequency-of-tapping-to-distance-to-beep-pitch\/\">Double Transducer: Frequency of Tapping to Distance to Beep Pitch<\/a><\/blockquote><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Double Transducer: Frequency of Tapping to Distance to Beep Pitch&#8221; &#8212; Intro to Physical Computing: Student Work Fall 2021\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/double-transducer-frequency-of-tapping-to-distance-to-beep-pitch\/embed\/#?secret=lGxmN18cUk\" data-secret=\"lGxmN18cUk\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\r\n*\/\r\n\r\n#include &lt;Wire.h&gt;\r\n#include &lt;LiquidCrystal_I2C.h&gt;\r\n#include &lt;Servo.h&gt;\r\nServo liftingArm;\r\nLiquidCrystal_I2C screen(0x3F, 16, 2);\r\n\r\n\/\/pin names\r\nconst int LEVERPIN = 6;\r\nconst int LEDPIN = 3;\r\nconst int PHOTOPIN = A2;\r\nconst int ARMPIN = 7;\r\n\r\n\/\/other variables\r\nunsigned long taps = 0;\r\nunsigned long lastSecond = 0;\r\nunsigned long lastThirdSecond = 0;\r\nfloat tapRate = 0;\r\nint switchVal = 0;\r\nint lightVal = 0;\r\nint liftingVal = 0;\r\nint photoVal = 0;\r\nint currSwitchVal = 0;\r\nint prevSwitchVal = 0;\r\nunsigned long tapB = 0;\r\nunsigned long tapA = 0;\r\n\r\n\/\/signal ranges\r\nconst int light_low = 0;\r\nconst int light_high = 255;\r\nconst int photo_low = 5;\r\nconst int photo_high = 630;\r\nconst int lift_low = 3;\r\nconst int lift_high = 75;\r\n\r\n\/\/Initialize the time between LCD display updates, and the timer itself.\r\nconst int LCDUPDATETIME = 250;\r\nlong prevDisplayTime = 0;\r\n\r\n\r\nvoid setup() {\r\n  pinMode(LEVERPIN, INPUT);\r\n  pinMode(LEDPIN, OUTPUT);\r\n  pinMode(PHOTOPIN, INPUT);\r\n  liftingArm.attach(ARMPIN);\r\n  Serial.begin(9600);\r\n  \/\/LCD Screen setup\r\n  screen.init();\r\n  screen.backlight();\r\n}\r\n\r\nvoid loop() {\r\n\r\n  \/\/Check current time.\r\n  long currentTime = millis();\r\n  currSwitchVal = digitalRead(6);\r\n\r\n  \/*when there is a transition in the switch position from off to on, count a tap\r\n     tapB tracks the time of the most recent tap, and tapA tracks the time of the prior tap\r\n  *\/\r\n  if (currSwitchVal == 1 and prevSwitchVal == 0) {\r\n    delay(3); \/\/debounce input signal\r\n    tapB = millis();\r\n    tapRate = 1000.0 \/ (tapB - tapA);\r\n    if (tapA == 0) {\r\n      tapRate = 0;\r\n    }\r\n    tapA = tapB;\r\n    \/\/set 3 taps\/sec as the maximum tapping rate\r\n    if (tapRate &gt; 3) {\r\n      tapRate = 3;\r\n    }\r\n  }\r\n\r\n  \/\/set tapping rate to 0 if over a second has passed since the last tap\r\n  if (millis () - tapA &gt; 1000) {\r\n    tapRate = 0;\r\n  }\r\n  prevSwitchVal = currSwitchVal;\r\n\r\n  \/\/update the LED brightness and servo motor arm height every second based on the tapping rate\r\n  if (millis() - lastSecond &gt;= 100) {\r\n    lightVal = map(tapRate * 10, 0, 3 * 10, light_low, light_high); \/\/map tapping rate to a brightness value\r\n    analogWrite(LEDPIN, lightVal); \/\/tell LED how bright it should be\r\n    photoVal = analogRead(PHOTOPIN); \/\/photoresistor sends brightness value to computer\r\n    liftingVal = map(photoVal, photo_low, photo_high, lift_low, lift_high); \/\/map brightness value to angle of arm\r\n    liftingArm.write(liftingVal); \/\/tells servo motor arm how high to lift\r\n    delay(10);\r\n    lastSecond = millis();\r\n  }\r\n\r\n  \/\/Update LCD display every 250 milliseconds.\r\n  if (currentTime - prevDisplayTime &gt;= LCDUPDATETIME) {\r\n    screen.clear();\r\n\r\n    \/\/Map tap rate to a range of 0-99 on LCD display.\r\n    int newtapRate = map(tapRate * 10, 0, 3 * 10, 0, 99);\r\n    screen.home();\r\n    screen.print(\"i:\");\r\n    screen.print(newtapRate);\r\n\r\n    \/\/Map brightness value to a range of 0-99 on LCD display.\r\n    int newlightVal = map(lightVal, light_low, light_high, 0, 99);\r\n    screen.setCursor(6, 0);\r\n    screen.print(\"m:\");\r\n    screen.print(newlightVal);\r\n\r\n    \/\/Map photoresistor values to a range of 0-99 on LCD display.\r\n    int newphotoVal = map(photoVal, photo_low, photo_high, 0, 99);\r\n    screen.setCursor(8, 1);\r\n    screen.print(newphotoVal);\r\n\r\n    \/\/Map height values to a range of 0-99 on LCD display.\r\n    int newliftingVal = map(liftingVal, lift_low, lift_high, 0, 99);\r\n    screen.setCursor(12, 1);\r\n    screen.print(\"o:\");\r\n    screen.print(newliftingVal);\r\n\r\n    prevDisplayTime = currentTime;\r\n\r\n  }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; &nbsp; Detail Photos: &nbsp; &nbsp; &nbsp; &nbsp; Videos: Video demonstration of Lynn&#8217;s double transducer. Video demonstration of Yongwen&#8217;s double transducer. Narrative Description: Our double transducer takes&#8230;<\/p>\n","protected":false},"author":217,"featured_media":15084,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15081"}],"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\/217"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/comments?post=15081"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15081\/revisions"}],"predecessor-version":[{"id":15126,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15081\/revisions\/15126"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media\/15084"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media?parent=15081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/categories?post=15081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/tags?post=15081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}