{"id":12289,"date":"2021-03-08T14:03:48","date_gmt":"2021-03-08T19:03:48","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/?p=12289"},"modified":"2021-03-08T16:45:42","modified_gmt":"2021-03-08T21:45:42","slug":"double-transducer-light-to-position-to-movement","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/double-transducer-light-to-position-to-movement\/","title":{"rendered":"Double Transducer: Light to Position to Movement"},"content":{"rendered":"<h2>Tinkercad Video<\/h2>\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-12289-1\" width=\"620\" height=\"395\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Circuit-design-Double-Transducer-Hares-_-Tinkercad-Google-Chrome-2021-03-06-23-34-35.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Circuit-design-Double-Transducer-Hares-_-Tinkercad-Google-Chrome-2021-03-06-23-34-35.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Circuit-design-Double-Transducer-Hares-_-Tinkercad-Google-Chrome-2021-03-06-23-34-35.mp4<\/a><\/video><\/div>\n<p>The potentiometer in this video is representative of our joystick middle step.<\/p>\n<h2>Overall photos for proportion and scale<\/h2>\n<h3>Tate<\/h3>\n<p>&nbsp;<\/p>\n<div id=\"attachment_12341\" style=\"width: 1266px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12341\" loading=\"lazy\" class=\"wp-image-12341 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1631.jpg\" alt=\"\" width=\"1256\" height=\"942\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1631.jpg 1256w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1631-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1631-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1631-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1631-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1631-508x381.jpg 508w\" sizes=\"(max-width: 1256px) 100vw, 1256px\" \/><p id=\"caption-attachment-12341\" class=\"wp-caption-text\">Tate&#8217;s final board<\/p><\/div>\n<p>My final version had correct transduction and displayed values at good fidelity, but even with an added transistor to the vibration motor it drew so much current that it would dim the LCD screen, but otherwise, this version had a functioning double transduction.<\/p>\n<h3>Dominique<\/h3>\n<div id=\"attachment_12299\" style=\"width: 1210px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12299\" loading=\"lazy\" class=\"wp-image-12299 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Dominiques-final-double-transducer-e1615097426797.jpeg\" alt=\"\" width=\"1200\" height=\"1196\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Dominiques-final-double-transducer-e1615097426797.jpeg 1200w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Dominiques-final-double-transducer-e1615097426797-300x300.jpeg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Dominiques-final-double-transducer-e1615097426797-1024x1021.jpeg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Dominiques-final-double-transducer-e1615097426797-150x150.jpeg 150w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Dominiques-final-double-transducer-e1615097426797-768x765.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Dominiques-final-double-transducer-e1615097426797-88x88.jpeg 88w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Dominiques-final-double-transducer-e1615097426797-973x970.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/Dominiques-final-double-transducer-e1615097426797-508x506.jpeg 508w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><p id=\"caption-attachment-12299\" class=\"wp-caption-text\">Dominique&#8217;s final board<\/p><\/div>\n<p>At first I thought my final version had some wiring issues surrounding the vibration motor, but upon closer inspection, and the addition of a replacement vibration motor, my double transducer actually worked fine. The LCD sensor and actuator values were being displayed properly, and luckily, it did not dim when the vibration motor was triggered, and I did not use a transistor, so this was a peculiar but happy outcome.<\/p>\n<h2>Final Working Version in Chain<\/h2>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-12289-2\" 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\/IMG_1728.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1728.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1728.mp4<\/a><\/video><\/div>\n<h2>Prototype Details<\/h2>\n<div id=\"attachment_12301\" style=\"width: 310px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12301\" loading=\"lazy\" class=\"wp-image-12301 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/unnamed-2-e1615097632563.jpg\" alt=\"\" width=\"300\" height=\"272\" \/><p id=\"caption-attachment-12301\" class=\"wp-caption-text\">At first our LCD had many display issues. First the backlight would not turn on, then the values flashed too fast, and so forth. After implementing a special delay in void loop and switching libraries, we were able to fix the problems, at least on one of our prototypes.<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_12342\" style=\"width: 663px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12342\" loading=\"lazy\" class=\"wp-image-12342 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1439.jpg\" alt=\"\" width=\"653\" height=\"871\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1439.jpg 653w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1439-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1439-508x678.jpg 508w\" sizes=\"(max-width: 653px) 100vw, 653px\" \/><p id=\"caption-attachment-12342\" class=\"wp-caption-text\">Servo-joystick prototyping<\/p><\/div>\n<p>We used our two prototypes to test different things, Dominique&#8217;s explored the LCD more and mine focused on the mechanical interface from servo to the joystick.<\/p>\n<h2>Prototype video<\/h2>\n<p><iframe title=\"Double Transducer Working Footage\" width=\"620\" height=\"349\" src=\"https:\/\/www.youtube.com\/embed\/7wwuAipTXC0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>Hopefully, you can hear the vibration motor buzzing in this video as I move the flashlight closer to the photoresistor on the other end of the board. And you can see the middle step (servo moving a joystick) as well. I had to cover the photoresistor with my hand in order to block out ambient light (that was really messing with the sensory data because it was a very bright room and my flashlight was dying), so you can&#8217;t quite see the flashlight action, but it&#8217;s happening, please trust me.<\/p>\n<h2>Simple narrative description<\/h2>\n<p>Our double transducer first takes in light in a room and records the brightness through the Arduino. That value is then used to determine the rotation degree of a servo motor; more light equals a higher degree up within a specified range. The servo pushes on a joystick, from which a y-Axis position is read and stored in Arduino. Finally, a vibration motor receives that output and vibrates more as the y-axis position increases.<\/p>\n<h2>Progress images<\/h2>\n<h3>Tate<\/h3>\n<p>&nbsp;<\/p>\n<div id=\"attachment_12343\" style=\"width: 1171px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12343\" loading=\"lazy\" class=\"wp-image-12343 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1610.jpg\" alt=\"\" width=\"1161\" height=\"871\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1610.jpg 1161w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1610-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1610-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1610-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1610-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1610-508x381.jpg 508w\" sizes=\"(max-width: 1161px) 100vw, 1161px\" \/><p id=\"caption-attachment-12343\" class=\"wp-caption-text\">LCD hieroglyph issues<\/p><\/div>\n<p>I struggled a lot with my LCD displaying odd values because of the vibration motor current draw creating noise in the circuit.<\/p>\n<h3><\/h3>\n<div id=\"attachment_12344\" style=\"width: 663px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12344\" loading=\"lazy\" class=\"wp-image-12344 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1609.jpg\" alt=\"\" width=\"653\" height=\"871\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1609.jpg 653w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1609-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/IMG_1609-508x678.jpg 508w\" sizes=\"(max-width: 653px) 100vw, 653px\" \/><p id=\"caption-attachment-12344\" class=\"wp-caption-text\">Servo-Joystick interface and soldering to protoboard<\/p><\/div>\n<p>I also struggled a lot with soldering, as I accidentally grabbed a non-powered protoboard so after soldering my adapters for the servo and joystick I had a long period of debugging to find the cause of that. It was good soldering practice because I had to bridge connections with quarter-inch lengths of wire.<\/p>\n<h3>Dominique<\/h3>\n<div id=\"attachment_12303\" style=\"width: 1210px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12303\" loading=\"lazy\" class=\"wp-image-12303 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/6009066B-3D7C-48AB-AC69-FCB0579D96B1.jpeg\" alt=\"\" width=\"1200\" height=\"1600\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/6009066B-3D7C-48AB-AC69-FCB0579D96B1.jpeg 1200w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/6009066B-3D7C-48AB-AC69-FCB0579D96B1-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/6009066B-3D7C-48AB-AC69-FCB0579D96B1-768x1024.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/6009066B-3D7C-48AB-AC69-FCB0579D96B1-1152x1536.jpeg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/6009066B-3D7C-48AB-AC69-FCB0579D96B1-973x1297.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/6009066B-3D7C-48AB-AC69-FCB0579D96B1-508x677.jpeg 508w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><p id=\"caption-attachment-12303\" class=\"wp-caption-text\">Prototyping popsicle stick connection<\/p><\/div>\n<p>The hardware for this circuit was actually relatively simple to build, at least on the breadboard. The hard part was configuring the delicate servo to properly trigger the joystick. So as you can see here, that problem has not been solved yet.<\/p>\n<div id=\"attachment_12313\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12313\" loading=\"lazy\" class=\"wp-image-12313 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/72ACBDE0-59D7-4A88-AC53-7FDF0F579F8F-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/72ACBDE0-59D7-4A88-AC53-7FDF0F579F8F-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/72ACBDE0-59D7-4A88-AC53-7FDF0F579F8F-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/72ACBDE0-59D7-4A88-AC53-7FDF0F579F8F-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/72ACBDE0-59D7-4A88-AC53-7FDF0F579F8F-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/72ACBDE0-59D7-4A88-AC53-7FDF0F579F8F-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/72ACBDE0-59D7-4A88-AC53-7FDF0F579F8F-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/72ACBDE0-59D7-4A88-AC53-7FDF0F579F8F-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-12313\" class=\"wp-caption-text\">LCD prototyping<\/p><\/div>\n<p>This was when the LCD still was not working properly. As you can see, it is not displaying anything, and that&#8217;s due to a number of reasons which are explained in detail in the Discussion section. The biggest problem here was that the LCD was wired incorrectly.<\/p>\n<h2>Discussion<\/h2>\n<p>Even though we went into the project anticipating the hardware components for wiring a transducer that involved a joystick would be complex, that part ended up not being that difficult and only took a short amount of time to configure.<\/p>\n<p>As far as the difficult aspects of the project, we ran into a lot of hiccups with writing to the LCD. One of the issues was especially mundane and we did not realize it; for the longest time, the LCD would not display any coherent information, despite the code looking to be fine. After consulting with Zach, we discovered that we were not using the right library the whole time. We were using commands from LiquidCrystal_I2C and but the LCD we have does not have the I2C backpack. So not only did we not realize we had a different LCD than the tutorials, we were wiring it wrong. Anyway, we sorted this, fortunately, but the LCD on one of the two double transducers we built still had issues we could not troubleshoot.<\/p>\n<p>We also had a strange issue where as our joystick value went up, the vibration intensity went down. We wanted both to increase in direct proportion. Turns out there was a typo for one of our map() functions where the value was reversed. Also we ended up writing a bit of extra code that constrained the max value of joystickVal which helped to keep our values in line.<\/p>\n<p>Tinkercad also had its own set of issues. because some inputs could not be sensed by Tinkercad, we had to &#8220;fake it.&#8221; It was interesting figuring out how to do this, but ultimately not too challenging. Since the first input is light, we could simply make that value increase and decrease automatically and the rest of the sensors and actuators respond accordingly. Because there&#8217;s no joystick in Tinkercad, we replaced it with a potentiometer, just to clarify.<\/p>\n<p>There&#8217;s also the issue of figuring out how to get the tiny servo arm to push the joystick, which does not budge very easily. We used superglue to glue half a popsicle stick to the arm, as you can see in the photos, and we taped down the motor, which did help. The motor on one transducer pushed sideways on the joystick, and the motor on the other was configured to push downward, and both seemed to work fine.<\/p>\n<p>Finally, for one of the two double transducers we built, it unfortunately broke after working properly a few times. The cause of the break is still kind of unknown even after checking the serial monitor and wiring. Because it was only the vibration motor that stopped responding even though the vibration value was displaying appropriately, we figured it was a wiring issue, one of the complications from a less-than-stellar soldering technique. It did look like the vibration wires were burned and not very attached, but after replacing the vibration motor and still finding issues, we figured the problem was deeper in the hardware. That was until I switched power sources and everything was completely fine. I agonized for hours over this very simple issue (Dominique).<\/p>\n<p>For future projects it certainly would be useful to get a better grasp on soldering with a steady hand. That did not seem to be my strong suit, and I&#8217;m sure it will be a useful skill for the future (Dominique).<\/p>\n<h2>Functional block diagram and schematic<\/h2>\n<div id=\"attachment_12310\" style=\"width: 941px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12310\" loading=\"lazy\" class=\"wp-image-12310 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/TransducerIdea1-e1615100620897.png\" alt=\"\" width=\"931\" height=\"411\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/TransducerIdea1-e1615100620897.png 931w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/TransducerIdea1-e1615100620897-300x132.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/TransducerIdea1-e1615100620897-768x339.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/TransducerIdea1-e1615100620897-508x224.png 508w\" sizes=\"(max-width: 931px) 100vw, 931px\" \/><p id=\"caption-attachment-12310\" class=\"wp-caption-text\">Block diagram<\/p><\/div>\n<div id=\"attachment_12311\" style=\"width: 1316px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-12311\" loading=\"lazy\" class=\"wp-image-12311 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/DoubleTransducerSchem.png\" alt=\"\" width=\"1306\" height=\"993\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/DoubleTransducerSchem.png 1306w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/DoubleTransducerSchem-300x228.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/DoubleTransducerSchem-1024x779.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/DoubleTransducerSchem-768x584.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/DoubleTransducerSchem-973x740.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/03\/DoubleTransducerSchem-508x386.png 508w\" sizes=\"(max-width: 1306px) 100vw, 1306px\" \/><p id=\"caption-attachment-12311\" class=\"wp-caption-text\">Schematic drawing<\/p><\/div>\n<h2>Here is the code<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/*\r\n  Double Transducer: Light to Position to Movement\r\n  Dominique Aruede and Tate Johnson\r\n\r\n  Description:\r\n  Takes in a light value which informs the degree rotation\r\n  of a servo arm which pushes a joystick which informs the\r\n  vibration intensity of a vibration motor.\r\n \r\n  Pin mapping:\r\n  Arduino pin | type   | description\r\n  ------------|--------|-------------\r\n  A0            input     photoresistor for initial input\r\n  A2            input     reads joystick x axis (only needed in this sketch to keep the y axis stable)\r\n  A3            input     reads joystick y axis\r\n  A4            input     reads vibration motor output\r\n  2             output    writes to pin D7 on LCD\r\n  3             output    writes to pin D6 on LCD\r\n  4             output    writes to pin D5 on LCD\r\n  5             output    writes to pin D4 on LCD\r\n  6             output    writes to vibration motor\r\n  8             output    writes to servo motor\r\n  11            output    writes to enable pin on LCD\r\n  12            output    writes to RS pin on LCD\r\n\r\n  Collaboration and sources:\r\n  - https:\/\/www.arduino.cc\/en\/Tutorial\/LibraryExamples\/HelloWorld\r\n  - https:\/\/canvas.cmu.edu\/courses\/22031\/modules (photoresistor asynchronous lecture)\r\n*\/\r\n\r\n#include &lt;Wire.h&gt;\r\n#include &lt;LiquidCrystal.h&gt;\r\n#include &lt;Servo.h&gt;\r\n\r\n\/\/pin constants\r\nconst int PHOTORESPIN = A0;\r\nconst int SERVOARMPIN = 8;\r\nconst int JOYSTICKPINx = A2;\r\nconst int JOYSTICKPINy = A3;\r\nconst int VIBRATIONPIN = 6;\r\nconst int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;\r\nconst int WAIT = 300;\r\nunsigned long timerVariable = 0;\r\n\r\n\r\nint lightVal = 0;\r\nint armVal = 0;\r\nint joystickVal = 0;\r\nint vibVal = 0;\r\n\r\n\/* Create an LCD display object called \"screen\" with I2C address 0x27\r\n    which is 16 columns wide and 2 rows tall.*\/\r\n\r\nLiquidCrystal lcd(rs, en, d4, d5, d6, d7);\r\nServo arm; \/\/ make a servo object\r\n\r\nvoid setup()\r\n{\r\n  \/\/ initiate pins\r\n  pinMode(PHOTORESPIN, INPUT);\r\n  pinMode(JOYSTICKPINy, INPUT);\r\n  pinMode(VIBRATIONPIN, OUTPUT);\r\n\r\n\r\n  \/\/ servo is plugged into the assigned pin on Arduino\r\n  arm.attach(SERVOARMPIN);\r\n\r\n  \/\/LCD setup\r\n  lcd.begin(16, 2);\r\n\r\n}\r\n\r\nvoid loop()\r\n{\r\n\r\n  \/\/digitalWrite(VIBRATIONPIN, HIGH);\r\n  \/\/convert light sensing to right range\r\n  lightVal = analogRead(PHOTORESPIN);\r\n  int LCDlightVal = 0;\r\n  LCDlightVal = map(lightVal, 0, 1023, 0, 99);\r\n\r\n  \/\/write to the transducer first part\r\n  armVal = map(lightVal, 0, 1023, 0, 170);\r\n  int LCDarmVal = 0;\r\n  LCDarmVal = map(lightVal, 0, 1023, 0, 99);\r\n  arm.write(armVal);\r\n\r\n  \/\/read the second transducer part\r\n  joystickVal = analogRead(JOYSTICKPINy);\r\n  if (joystickVal &gt;= 512) {\r\n    joystickVal = joystickVal - 512;\r\n  }\r\n  else {\r\n    joystickVal = 0;\r\n  }\r\n  int LCDjoystickVal = 0;\r\n  LCDjoystickVal = map(joystickVal, 0, 512, 0, 99);\r\n\r\n  \/\/ write to output\r\n  vibVal = map(joystickVal, 0, 512, 0, 255);\r\n  analogWrite(VIBRATIONPIN, vibVal);\r\n  int LCDvibVal = 0;\r\n  LCDvibVal = map(vibVal, 0, 255, 0, 99);\r\n\r\n\r\n  if (millis() - timerVariable &gt; WAIT) {\r\n    lcd.clear();\r\n    lcd.home();\r\n    lcd.print(\"i:\");\r\n    lcd.print(LCDlightVal);\r\n    lcd.print(\"  m:\");\r\n    lcd.print(LCDarmVal);\r\n    lcd.setCursor(8, 1);\r\n    lcd.print(LCDjoystickVal);\r\n    lcd.setCursor(12, 1);\r\n    lcd.print(\"o:\");\r\n    lcd.print(LCDvibVal);\r\n    timerVariable = millis();\r\n  }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tinkercad Video The potentiometer in this video is representative of our joystick middle step. Overall photos for proportion and scale Tate &nbsp; My final version had correct transduction&#8230;<\/p>\n","protected":false},"author":169,"featured_media":12294,"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\/12289"}],"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\/169"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/comments?post=12289"}],"version-history":[{"count":25,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/12289\/revisions"}],"predecessor-version":[{"id":12347,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/12289\/revisions\/12347"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media\/12294"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media?parent=12289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/categories?post=12289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/tags?post=12289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}