{"id":12322,"date":"2021-03-09T21:03:40","date_gmt":"2021-03-10T02:03:40","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/?p=12322"},"modified":"2021-03-10T09:04:48","modified_gmt":"2021-03-10T14:04:48","slug":"frogs-double-transducer","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/frogs-double-transducer\/","title":{"rendered":"Double Transducer: Pressure &#8211;&gt; Light &#8211;&gt; Orientation"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignnone wp-image-12387\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9283-scaled.jpg\" alt=\"\" width=\"1257\" height=\"943\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9283-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9283-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9283-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9283-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9283-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9283-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9283-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9283-508x381.jpg 508w\" sizes=\"(max-width: 1257px) 100vw, 1257px\" \/><\/p>\n<h1 style=\"text-align: center\">Double Transducer<\/h1>\n<h2>Images<\/h2>\n<h4 style=\"text-align: center\">Overall Photos<\/h4>\n<p style=\"text-align: center\"><img loading=\"lazy\" class=\"alignnone wp-image-12447 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9284-scaled-e1615321230229.jpeg\" alt=\"\" width=\"524\" height=\"391\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9284-scaled-e1615321230229.jpeg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9284-scaled-e1615321230229-300x224.jpeg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9284-scaled-e1615321230229-1024x764.jpeg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9284-scaled-e1615321230229-768x573.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9284-scaled-e1615321230229-1536x1146.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9284-scaled-e1615321230229-973x726.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9284-scaled-e1615321230229-508x379.jpeg 508w\" sizes=\"(max-width: 524px) 100vw, 524px\" \/><\/p>\n<p style=\"text-align: center\">(Jud)<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" class=\"alignnone size-large wp-image-12590\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158920842_339219300845726_2023316460482419723_n-e1615349860305-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158920842_339219300845726_2023316460482419723_n-e1615349860305-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158920842_339219300845726_2023316460482419723_n-e1615349860305-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158920842_339219300845726_2023316460482419723_n-e1615349860305-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158920842_339219300845726_2023316460482419723_n-e1615349860305-508x381.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158920842_339219300845726_2023316460482419723_n-e1615349860305-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158920842_339219300845726_2023316460482419723_n-e1615349860305.jpg 1104w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p style=\"text-align: center\">(Jun)<\/p>\n<h4 style=\"text-align: center\">Detail Photos<\/h4>\n<p style=\"text-align: center\"><img loading=\"lazy\" class=\"alignnone wp-image-12449\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9288-scaled-e1615321320457.jpeg\" alt=\"\" width=\"548\" height=\"391\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9288-scaled-e1615321320457.jpeg 2252w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9288-scaled-e1615321320457-300x214.jpeg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9288-scaled-e1615321320457-1024x730.jpeg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9288-scaled-e1615321320457-768x548.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9288-scaled-e1615321320457-1536x1095.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9288-scaled-e1615321320457-2048x1461.jpeg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9288-scaled-e1615321320457-973x694.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9288-scaled-e1615321320457-508x362.jpeg 508w\" sizes=\"(max-width: 548px) 100vw, 548px\" \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<img loading=\"lazy\" class=\"alignnone wp-image-12450\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9286-scaled-e1615321419741.jpeg\" alt=\"\" width=\"575\" height=\"391\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9286-scaled-e1615321419741.jpeg 2316w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9286-scaled-e1615321419741-300x204.jpeg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9286-scaled-e1615321419741-1024x696.jpeg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9286-scaled-e1615321419741-768x522.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9286-scaled-e1615321419741-1536x1044.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9286-scaled-e1615321419741-2048x1392.jpeg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9286-scaled-e1615321419741-973x661.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_9286-scaled-e1615321419741-508x345.jpeg 508w\" sizes=\"(max-width: 575px) 100vw, 575px\" \/><\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" class=\"alignnone wp-image-12480\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/159289324_130041509037389_113659247623473415_n-768x1024.jpg\" alt=\"\" width=\"461\" height=\"615\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/159289324_130041509037389_113659247623473415_n-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/159289324_130041509037389_113659247623473415_n-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/159289324_130041509037389_113659247623473415_n-508x677.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/159289324_130041509037389_113659247623473415_n.jpg 828w\" sizes=\"(max-width: 461px) 100vw, 461px\" \/><\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" class=\"alignnone wp-image-12479\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158860831_445710643407001_6005806539992302596_n-768x1024.jpg\" alt=\"\" width=\"475\" height=\"633\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158860831_445710643407001_6005806539992302596_n-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158860831_445710643407001_6005806539992302596_n-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158860831_445710643407001_6005806539992302596_n-508x677.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158860831_445710643407001_6005806539992302596_n.jpg 828w\" sizes=\"(max-width: 475px) 100vw, 475px\" \/><\/p>\n<h4 style=\"text-align: center\">Transducers in Action<\/h4>\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-12322-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\/Final_Demonstration.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Final_Demonstration.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Final_Demonstration.mp4<\/a><\/video><\/div>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12322-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\/video-1615355253.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/video-1615355253.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/video-1615355253.mp4<\/a><\/video><\/div>\n<h2 style=\"text-align: left\">TinkerCAD Simulation<\/h2>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12322-3\" width=\"620\" height=\"436\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/TinkerCAD_Screen_Capture.mp4?_=3\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/TinkerCAD_Screen_Capture.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/TinkerCAD_Screen_Capture.mp4<\/a><\/video><\/div>\n<h2 style=\"text-align: left\">Narrative Description<\/h2>\n<p><span style=\"font-weight: 400\">The cardboard stand on the left of the transducer has a pressure sensor attached to it which senses how hard it is pressed. Based off of this pressure, a light inside of the cardboard box turns on to a specific brightness. If the pressure sensor is pushed hard, then the light turns on very bright, and if it is pressed lightly, then the light is very dim. Inside of this box is also a light sensor that senses this change in the clear light&#8217;s brightness. According to the amount of change that occurs, a servo on the left side of the mechanism turns around. If the amount of light in the box increases, then the servo rotates counter-clockwise to match this amount of change. As all of this is happening, a display at the bottom of the machine shows the numeric values of all of these actions starting with the pressure sensor in the top left and ending with the servo in the bottom right of the screen.<\/span><\/p>\n<h2>Process<\/h2>\n<p><img loading=\"lazy\" class=\" wp-image-12474 aligncenter\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158591173_4176734429027680_3175068898347861661_n-768x1024.jpg\" alt=\"\" width=\"435\" height=\"580\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158591173_4176734429027680_3175068898347861661_n-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158591173_4176734429027680_3175068898347861661_n-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158591173_4176734429027680_3175068898347861661_n-508x677.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/158591173_4176734429027680_3175068898347861661_n.jpg 828w\" sizes=\"(max-width: 435px) 100vw, 435px\" \/><\/p>\n<p style=\"text-align: center\">This image shows the soldering of the color sensor that we were originally going to use. The soldering was successfully done, and the device was working, but we decided not to use this sensor.<\/p>\n<p><img loading=\"lazy\" class=\"wp-image-12389 aligncenter\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_1-scaled.jpg\" alt=\"\" width=\"896\" height=\"672\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_1-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_1-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_1-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_1-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_1-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_1-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_1-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_1-508x381.jpg 508w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/p>\n<p style=\"text-align: center\"><span style=\"font-weight: 400\">This image depicts the testing of the color output using three different color LED\u2019s to see what was causing our multi-colored LED issue discussed later on.<\/span><\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" class=\"alignnone wp-image-12390\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_2-scaled.jpg\" alt=\"\" width=\"732\" height=\"549\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_2-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_2-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_2-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_2-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_2-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_2-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_2-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Process_Image_2-508x381.jpg 508w\" sizes=\"(max-width: 732px) 100vw, 732px\" \/><\/p>\n<p style=\"text-align: center\"><span style=\"font-weight: 400\">This image shows the final step of the soldering process where our switch from color sensing to brightness became permanent.<\/span><\/p>\n<h2><img loading=\"lazy\" class=\"wp-image-12473 aligncenter\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/2.jpg\" alt=\"\" width=\"497\" height=\"663\" \/><\/h2>\n<p style=\"text-align: center\">This image shows the process of adding the potentiometer to the LCD in order to adjust its brightness. Initially, the v0 was connected to the ground instead of the potentiometer, and we were not able to adjust its brightness.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>Discussion<\/h2>\n<p><span style=\"font-weight: 400\">The hardest part about this project was understanding how to use each of the components and figure out accurate mapping functions to make sure each component was being used to its full potential. The hardest component accomplish this with was the color sensor because of its 3 inputs. Since the color sensor has red, green, and blue inputs, the Force Sensitive Resistor&#8217;s (FSR) single output made connecting these two elements very challenging. In the end, after relentlessly searching for algorithms that would accomplish this goal for us, we decided to pursue an alternative method utilizing brightness instead. Reflecting back on this decision, however, it would&#8217;ve been a better idea to start out with trying to understand this conversion process and write our own algorithm as opposed to searching the internet for one we could implement. This could have possibly improved our ability to understand these converting algorithms later on if we needed to use them which may have resulted in the final product including this middle sensor.\u00a0<\/span><\/p>\n<p>Apart from this color sensing dilemma, we also ran into issues while trying to use the servo library and analogWrite functionality together. During our first testing stages of the different components, we had the multi-colored LED wired in such a way that it would receive PWM signals from pins 6, 9, and 10. Upon plugging everything in and trying to change the color of the LED, only the LED plugged into pin 6 would produce the desired effect. After lots of time spent trying to debug the circuit, we finally figured out that the issue existed with the way that the servo library interacts with the Arduino. In order for the servo library to function, part of the code disables the analogWrite function for pins 9 and 10 making our original circuit diagram invalid. Just switching the input pin placement for these LED&#8217;s fixed our problem entirely.<\/p>\n<p><span style=\"font-weight: 400\">Reflecting back on the creativity of the project, it would\u2019ve been both easier and more exciting\/interesting to only use the red and blue LED&#8217;s for the middle step of the transducer. This would not only make the code simpler by removing the need to map one input to three values and back, but it would also have a more physical meaning aligning closer to traditional ways of depicting pressure. Adding this element could have made the transducer a little bit more interactive helping to produce a more meaningful interaction than what this final version creates.\u00a0<\/span><\/p>\n<h2>Functional Block Diagram<\/h2>\n<p><img loading=\"lazy\" class=\"size-full wp-image-12522 aligncenter\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Functional_Block_Diagram-1.jpg\" alt=\"\" width=\"735\" height=\"337\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Functional_Block_Diagram-1.jpg 735w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Functional_Block_Diagram-1-300x138.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Functional_Block_Diagram-1-508x233.jpg 508w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><\/p>\n<h2>Electrical Schematic<\/h2>\n<p><img loading=\"lazy\" class=\"size-full wp-image-12526 aligncenter\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Electrical_Schematic-1.jpg\" alt=\"\" width=\"896\" height=\"833\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Electrical_Schematic-1.jpg 896w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Electrical_Schematic-1-300x279.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Electrical_Schematic-1-768x714.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Electrical_Schematic-1-508x472.jpg 508w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/p>\n<h2>Code<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/*\r\n   60-223, Double Transducer\r\n   Judson Kyle  (judsonk)\r\n   Hyojun Jeong (hyojunj)\r\n\r\n   Collaboration and sources:\r\n   1) Used sample from Code Bites page on the 60-223 Intro to Physical \r\n      Computing website for serial communication to the MQTT bridge application\r\n\r\n   Description: This double transducer will convert pressure to light\r\n   to orientation through the use of a Force Sensitive Resistor (FSR),\r\n   a photoresistor, and a servo. The input of the FSR will drive the\r\n   brightness of an LED which is in an enclosed box with the photoresistor.\r\n   The photoresistor will read the LED brghtness and map it to an angle\r\n   which the servo can travel to. This will continuously happen until\r\n   the system is turned off. In addition, the input and output values for\r\n   each sensor and output will be mapped to a value from 0-99 and then\r\n   displayed in an LCD screen with the FSR reading on the top left, the \r\n   LED birghtness in the middle top, the photoresistor reading in the bottom\r\n   middle, and the servo output in the bottom right.\r\n   \r\n   Pin mapping:\r\n\r\n   Arduino pin | type   | description\r\n   ------------|--------|-------------\r\n   A0            input     Force Sensitive Resistor for sensing pressure\r\n   A1            input     Photoresistor for sensing birhgtness ofLED\r\n   3             output    LED pin for controlling brightness\r\n   4             output    LCD enable pin\r\n   7             output    LCD register select pin\r\n   8             output    LCD pin D4\r\n   9             output    LCD pin D3\r\n   10            output    LCD pin D6\r\n   11            output    Servo pin for control of servo's angle\r\n   12            output    LCD pin D7\r\n*\/\r\n\r\n\/\/Include Libraries for LCD and Servo Motor\r\n#include &lt;LiquidCrystal.h&gt;\r\n#include &lt;Servo.h&gt;\r\n\r\n\/\/FSR pins\r\nconst int FSRPIN = A0;\r\n\r\n\/\/Photoresistor and LED pins\r\nconst int PHOTOPIN = A1, LEDPIN = 3;\r\n\r\n\/\/Servo object and variable creation\r\nServo gauge;              \/\/Create servo object \"gauge\"\r\nint pos = 0;              \/\/Set pos varible to 0 (stores position of servo)\r\nconst int SERVOPIN = 5;   \/\/Variable holding servo pin number\r\n\r\n\/\/LCD object creation and pin attachment\r\nconst int en = 4, rs = 7, d7 = 12, d6 = 10, d5 = 9, d4 = 8;\r\nLiquidCrystal lcd(rs, en, d4, d5, d6, d7);\r\n\r\n\/\/Prepare timing values to reduce delay of writing to LCD\r\nconst int waitingValue = 100; \/\/ Time delay between readings\r\nunsigned long lastTime = 0;   \/\/ Variable to store the most recent time\r\n\r\n\/\/MQTT Variables\r\nconst unsigned long WAIT = 250; \/\/25sec\r\nunsigned long timer;\r\n\r\nint inVal, outVal;\r\n\r\n\/\/Code to run once\r\nvoid setup() {\r\n\r\n  \/\/LCD Initialization\r\n  lcd.begin(16, 2);\r\n  lcd.print(\"Hello\");\r\n\r\n  \/\/Define inputs\r\n  pinMode(FSRPIN, INPUT);\r\n  pinMode(PHOTOPIN, INPUT);\r\n\r\n  \/\/Define outputs\r\n  pinMode(LEDPIN, OUTPUT);\r\n\r\n  \/\/Set gauge object to read from SERVOPIN\r\n  gauge.attach(SERVOPIN);\r\n  \r\n  Serial.begin(115200); \/\/ qt_arduino_mqtt_bridge uses this rate\r\n  Serial.setTimeout(50); \/\/ wait \u2264 50 milliseconds to parse incoming data\r\n\r\n}\r\n\r\n\/\/Code to loop through\r\nvoid loop() {\r\n\r\n\/\/  \/\/Recieve input from previous transducer\r\n\/\/  int ledVal = map(inVal, 0, 99, 0, 255);\r\n  \r\n  \/\/Convert pressure into light\r\n  int fsrValue = analogRead(FSRPIN); \/\/Read FSR value and sotre in fsrValue\r\n\r\n  int ledVal = map(fsrValue, 0, 1000, 0, 255); \/\/convert pressure to PWM signal\r\n  \r\n  analogWrite(LEDPIN, ledVal); \/\/Display brightness\r\n  \/\/Convert light into servo orientation\r\n  int photoVal = analogRead(PHOTOPIN); \/\/Read photoresistor to get brightness\r\n  int servoAngle = map(photoVal, 0, 750, 0, 180); \/\/Convert brightss to degreeof rotation\r\n \r\n  \/\/Rotate servo to correct angle and wait for it to get there\r\n  gauge.write(servoAngle);\r\n  delay(15);\r\n\r\n  \/\/Output to LCD after every time interval\r\n  if (millis() - lastTime &gt; waitingValue) {\r\n    lcd.clear();\r\n    lcd.print(\"i:\" + String(map(fsrValue, 0, 1000, 0, 99))); \/\/Print FSR input value in 0-99 range\r\n    \r\n    \/\/Set location of next print line to middle of the first row\r\n    lcd.setCursor(6, 0);\r\n    lcd.print(\"m:\" + String(map(ledVal, 0, 255, 0, 99))); \/\/ Print LED value in 0-99 range\r\n    \r\n    \/\/Set location of next print to be the bottom middle of the LCD\r\n    lcd.setCursor(6, 1);\r\n    lcd.print(String(map(photoVal, 0, 750, 0, 99))); \/\/color sensor output value in 0-99 range\r\n    \r\n    \/\/Set location of next print to be the bottom right of the LCD\r\n    lcd.setCursor(11, 1);\r\n    lcd.print(\"o:\" + String(map(servoAngle, 0, 170, 0, 99))); \/\/ Print servo output value in 0-99 range\r\n    lastTime = millis();\r\n  }\r\n\r\n  \/\/Transmit output data to next device\r\n  if (millis() - timer &gt; WAIT){\r\n    outVal = map(servoAngle, 0, 170, 0, 99);\r\n    transmitSerialSignal();\r\n    timer = millis();\r\n  }\r\n}\r\n\r\nvoid serialEvent(){\r\n  \/*  You do *not* need to call this function in your loop;\r\n      it is a special function that will run whenever serial\r\n      data flows into the Arduino. *\/\r\n  \r\n  \/*  The function assumes your machine's input value \r\n      is called \"inVal\" (change that variable name as needed) *\/\r\n\r\n  \/\/ if there is incoming serial data, read it\r\n  while (Serial.available() &gt; 0){\r\n    \/\/ interpret incoming digits as integer and save into inVal\r\n    inVal = Serial.read();\r\n  }\r\n}\r\n\r\nvoid transmitSerialSignal(){\r\n  \/* You should call this function 2-4 times\/second in your\r\n     main loop to transmit information to the next Arduino\r\n     in the transmission chain. *\/\r\n  \r\n  \/* Assumes your machine's outgoing value is called outVal\r\n     (change that variable name as needed) *\/\r\n  Serial.println(outVal);\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Double Transducer Images Overall Photos (Jud) (Jun) Detail Photos \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Transducers in Action TinkerCAD Simulation Narrative Description The cardboard stand&#8230;<\/p>\n","protected":false},"author":173,"featured_media":12387,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[86,1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/12322"}],"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\/173"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/comments?post=12322"}],"version-history":[{"count":24,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/12322\/revisions"}],"predecessor-version":[{"id":12675,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/12322\/revisions\/12675"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media\/12387"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media?parent=12322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/categories?post=12322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/tags?post=12322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}