{"id":13995,"date":"2021-10-05T01:54:56","date_gmt":"2021-10-05T05:54:56","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/?p=13995"},"modified":"2021-10-05T01:54:56","modified_gmt":"2021-10-05T05:54:56","slug":"double-transducer-color-to-rotational-position","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/double-transducer-color-to-rotational-position\/","title":{"rendered":"Double Transducer: Color to Rotational Position"},"content":{"rendered":"<blockquote>\n<h2>Color to Rotational Position<\/h2>\n<\/blockquote>\n<p>Our double transducer took color as an input, transforming it into rotational position.<\/p>\n<div id=\"attachment_14025\" style=\"width: 2280px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14025\" loading=\"lazy\" class=\"wp-image-14025 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer1-scaled.jpg\" alt=\"\" width=\"2270\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer1-scaled.jpg 2270w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer1-266x300.jpg 266w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer1-908x1024.jpg 908w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer1-768x866.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer1-1362x1536.jpg 1362w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer1-1816x2048.jpg 1816w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer1-973x1097.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer1-508x573.jpg 508w\" sizes=\"(max-width: 2270px) 100vw, 2270px\" \/><p id=\"caption-attachment-14025\" class=\"wp-caption-text\">The final double transducer, copy 1.<\/p><\/div>\n<div id=\"attachment_14026\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14026\" loading=\"lazy\" class=\"wp-image-14026 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer2-scaled.jpg\" alt=\"\" width=\"2560\" height=\"2433\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer2-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer2-300x285.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer2-1024x973.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer2-768x730.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer2-1536x1460.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer2-2048x1946.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer2-973x925.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/transducer2-508x483.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-14026\" class=\"wp-caption-text\">The second copy of the double transducer we made.<\/p><\/div>\n<p>The first part is the color sensor (at the top of the images), which reads what color is put in front of it. After turning it on, we make sure the color sensor is at the correct position, so we have to put a color in front of it and press the button, which makes 1\/10th of a full rotation, until the color sensor is pointing to the correct location on the color wheel. When a different color is put in front of the color sensor, the color sensor reads the color and spins the motor to point to the color we are reading. The position of the motor puts pressure on a different sensor. Depending on what location the second sensor is being pressed, the final motor turns a certain amount.<\/p>\n<h2>Detail Shots<\/h2>\n<div id=\"attachment_14021\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14021\" loading=\"lazy\" class=\"wp-image-14021 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/holding-up-the-potentiometer-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/holding-up-the-potentiometer-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/holding-up-the-potentiometer-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/holding-up-the-potentiometer-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/holding-up-the-potentiometer-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/holding-up-the-potentiometer-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/holding-up-the-potentiometer-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/holding-up-the-potentiometer-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/holding-up-the-potentiometer-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-14021\" class=\"wp-caption-text\">Detail shot: the small pillars we added in order to stabilize the potentiometer input.<\/p><\/div>\n<div id=\"attachment_14020\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14020\" loading=\"lazy\" class=\"wp-image-14020 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail3-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail3-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail3-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail3-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail3-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail3-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail3-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail3-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail3-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-14020\" class=\"wp-caption-text\">Detail shot: the arm attached to the stepper motor which puts pressure on the potentiometer.<\/p><\/div>\n<div id=\"attachment_14019\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14019\" loading=\"lazy\" class=\"wp-image-14019 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail2-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail2-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail2-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail2-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail2-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail2-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail2-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail2-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail2-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-14019\" class=\"wp-caption-text\">Detail shot: the soldered board.<\/p><\/div>\n<div id=\"attachment_14018\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14018\" loading=\"lazy\" class=\"wp-image-14018 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/detail-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-14018\" class=\"wp-caption-text\">Detail shot: The second color sensor, with a busted LED that we had to replace.<\/p><\/div>\n<h2>Progress Images<\/h2>\n<div id=\"attachment_14028\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14028\" loading=\"lazy\" class=\"wp-image-14028 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip2-scaled.jpg\" alt=\"potentiometer test 1\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip2-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip2-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip2-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip2-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip2-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip2-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip2-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-14028\" class=\"wp-caption-text\">Our day 1 design for the potentiometer. Unstable, ultimately redone.<\/p><\/div>\n<div id=\"attachment_14027\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14027\" loading=\"lazy\" class=\"wp-image-14027 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/wip-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-14027\" class=\"wp-caption-text\">First attempt at getting the stepper motor to work<\/p><\/div>\n<div id=\"attachment_14037\" style=\"width: 1034px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14037\" loading=\"lazy\" class=\"wp-image-14037 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/596C680A-01D4-42F2-87F9-0F188FCC24C8_1_105_c.jpeg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/596C680A-01D4-42F2-87F9-0F188FCC24C8_1_105_c.jpeg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/596C680A-01D4-42F2-87F9-0F188FCC24C8_1_105_c-300x225.jpeg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/596C680A-01D4-42F2-87F9-0F188FCC24C8_1_105_c-768x576.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/596C680A-01D4-42F2-87F9-0F188FCC24C8_1_105_c-973x730.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/596C680A-01D4-42F2-87F9-0F188FCC24C8_1_105_c-508x381.jpeg 508w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><p id=\"caption-attachment-14037\" class=\"wp-caption-text\">First working color sensor to stepper motor rotation to potentiometer read<\/p><\/div>\n<div id=\"attachment_14036\" style=\"width: 778px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14036\" loading=\"lazy\" class=\"wp-image-14036 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/65EC6395-3340-4663-8A6B-8F43D007BAA4_1_105_c.jpeg\" alt=\"\" width=\"768\" height=\"1024\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/65EC6395-3340-4663-8A6B-8F43D007BAA4_1_105_c.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/65EC6395-3340-4663-8A6B-8F43D007BAA4_1_105_c-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/65EC6395-3340-4663-8A6B-8F43D007BAA4_1_105_c-508x677.jpeg 508w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><p id=\"caption-attachment-14036\" class=\"wp-caption-text\">Finished the soldering on the first board, and verified that the motor works.<\/p><\/div>\n<h2>Discussion<\/h2>\n<p>The first day we spent the entire two hours of class trying to work with the force sensing circular potentiometer, trying to get a consistent reading on it. We fiddled with it for ages, trying to find something that could move and apply enough pressure to the potentiometer for it to consistently register. Our first attempt at this was to add weights to the pointer part of the arm that would apply pressure. However, by the end of it, it still wasn\u2019t working, and we had to consider our options. We came up with a few: first, we could continue working with the potentiometer, with our next steps being that we would move it to a more stable surface; and two, we could create what was basically our own potentiometer by moving a stepper motor with resistors surrounding it and measuring the change in voltage. However we did end up making the circular potentiometer work by creating a more stable surface, and adding support beams and weights to the arm. This was definitely the hardest part of the project.<\/p>\n<p>Something that initially seemed fairly daunting, was soldering. Neither of us had much experience with soldering in the past, and the number of pins that needed to be soldered to run the stepper motor was very scary. However, after the first 10-15 pins, the we picked up a feel for how to work the soldering iron and make pretty solders. The second board soldering process went by much faster, and overall would say that soldering feels fairly easy now especially considering where we started.<\/p>\n<p>One decision that would have changed everything about what we learned and how cool our project ended up being, is using the easy middle step that we had initially discussed. One of our three initial ideas was to use the brightness of a bulb to change a photoresistor resistance and measure that change. We would have had a much easier soldering step, which means we would likely not have been as comfortable as we are now with it, and it also would have removed the entire centerpiece of our final design, which was the color wheel to stepper motor interaction that lets us display color.<\/p>\n<h2>Functional Block Diagram<\/h2>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/double-transducer.drawio-1.svg\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-14033\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/double-transducer.drawio-1.svg\" alt=\"\" width=\"1638\" height=\"342\" \/><\/a><\/p>\n<h2>Schematic<\/h2>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-14051 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/Electrical-Diagram-Project-1-Ideas.drawio-e1633395214501.png\" alt=\"\" width=\"1086\" height=\"706\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/Electrical-Diagram-Project-1-Ideas.drawio-e1633395214501.png 1351w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/Electrical-Diagram-Project-1-Ideas.drawio-e1633395214501-300x195.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/Electrical-Diagram-Project-1-Ideas.drawio-e1633395214501-1024x666.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/Electrical-Diagram-Project-1-Ideas.drawio-e1633395214501-768x500.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/Electrical-Diagram-Project-1-Ideas.drawio-e1633395214501-973x633.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/Electrical-Diagram-Project-1-Ideas.drawio-e1633395214501-508x331.png 508w\" sizes=\"(max-width: 1086px) 100vw, 1086px\" \/><\/p>\n<h2><\/h2>\n<h2>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-13995-1\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/epic-demo.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/epic-demo.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/10\/epic-demo.mp4<\/a><\/video><\/div>\n<p>A video demonstration of the color wheel working. There is a slight delay between the color input and the movement of the motors; this is due to the calculations made to get the raw data from the sensors.<\/p>\n<h2>Code<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/*\r\nDouble Transducer: Color to Rotational Position\r\n\r\n1. Reads values from the color sensor, \r\n2. Converts it into a degree value based on the color sensed from the color sensor\r\n3. Moves stepper motor stepwise until it reaches the number of degrees we got from the color sensor\r\n4. Reads potentiometer reading \r\n5. Translate potentiometer reading into an amount to move the final servo motor\r\n\r\nCredit: https:\/\/www.py4u.net\/discuss\/63122 for the code to convert rgb values to hsv values\r\n*\/\r\n#include &lt;AccelStepper.h&gt;\r\n#include &lt;Servo.h&gt;\r\n#include &lt;Wire.h&gt;\r\n#include \"Adafruit_TCS34725.h\"\r\n#include &lt;LiquidCrystal_I2C.h&gt;\r\n\r\n\r\nconst int STEP_PIN = 12; \/\/ A4988 \"STEP\" pin wired to Arduino pin 2 for stepper \r\nconst int DIR_PIN = 13; \/\/ A4988 \"DIRECTION\" pin wired to Arduino pin 3 for stepper motor\r\nconst int buttonPin = 2; \/\/ pin for button press\r\nconst int servoPin = 3;  \/\/ pin for controlling servo motor\r\nAdafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_614MS, TCS34725_GAIN_1X);\r\nLiquidCrystal_I2C lcd(0x27, 16, 2); \/\/ initializes \r\n\r\ntypedef struct {\r\n    double h;       \/\/ angle in degrees\r\n    double s;       \/\/ a fraction between 0 and 1\r\n    double v;       \/\/ a fraction between 0 and 1\r\n} hsv;\r\n \r\nstatic hsv   rgb2hsv(float r, float g, float b);\r\n\r\n\/\/ converts rgb values to hsv values\r\nhsv rgb2hsv(float r, float g, float b) \r\n{\r\n    hsv         out;\r\n    double      min, max, delta;\r\n \r\n    min = r &lt; g ? r : g;\r\n    min = min  &lt; b ? min  : b;\r\n \r\n    max = r &gt; g ? r : g;\r\n    max = max  &gt; b ? max  : b;\r\n \r\n    out.v = max;                                \/\/ v\r\n    delta = max - min;\r\n    if (delta &lt; 0.00001)\r\n    {\r\n        out.s = 0;\r\n        out.h = 0; \/\/ undefined, maybe nan?\r\n        return out;\r\n    }\r\n    if( max &gt; 0.0 ) { \/\/ NOTE: if Max is == 0, this divide would cause a crash\r\n        out.s = (delta \/ max);                  \/\/ s\r\n    } else {\r\n        \/\/ if max is 0, then r = g = b = 0              \r\n        \/\/ s = 0, h is undefined\r\n        out.s = 0.0;\r\n        out.h = NAN;                            \/\/ its now undefined\r\n        return out;\r\n    }\r\n    if( r &gt;= max )                           \/\/ &gt; is bogus, just keeps compilor happy\r\n        out.h = ( g - b ) \/ delta;        \/\/ between yellow &amp; magenta\r\n    else\r\n    if( g &gt;= max )\r\n        out.h = 2.0 + ( b - r ) \/ delta;  \/\/ between cyan &amp; yellow\r\n    else\r\n        out.h = 4.0 + ( r - g ) \/ delta;  \/\/ between magenta &amp; cyan\r\n \r\n    out.h *= 60.0;                              \/\/ degrees\r\n \r\n    if( out.h &lt; 0.0 )\r\n        out.h += 360.0;\r\n \r\n    return out;\r\n}\r\n\r\nServo serv;\r\n\r\n\/\/ make an AccelStepper motor object. \r\nAccelStepper myMotor(1, STEP_PIN, DIR_PIN);\r\n\r\nlong long count = 0;\r\nlong total = 0;\r\nlong sampleSize = 0;\r\n\r\nint calibPos = 0;\r\nint pos = 0;\r\nlong long setPosTimer = 0;\r\nlong long buttonTimer = 0;\r\n\r\nlong long \r\nint degree = 0;\r\nchar color[20];\r\n\r\n\r\nvoid setup(){\r\n  Serial.begin(9600); \/\/ begin Serial communication\r\n  pinMode(buttonPin, INPUT);\r\n  \/\/checks color sensor is working\r\n  Serial.println(\"setupr\");\r\n  if (tcs.begin()) {\r\n    Serial.println(\"Found sensor\");\r\n  } else {\r\n    Serial.println(\"No TCS34725 found ... check your connections\");\r\n    while (1);\r\n  } \r\n\r\n  \/\/ starts the display\r\n  lcd.begin();\r\n  lcd.backlight();\r\n  lcd.print(\"Hi!\");\r\n  \r\n  \/\/ you can change the below values as you'd like\r\n  myMotor.setMaxSpeed(150); \/\/ measured in steps per second\r\n  myMotor.setAcceleration(50); \/\/ measured in steps per second squared\r\n  serv.attach(servoPin);\r\n\r\n  setPosTimer = millis();\r\n  myMotor.moveTo(0);\r\n\r\n  while(myMotor.distanceToGo() != 0) {\r\n    myMotor.run();\r\n  }\r\n}\r\n\r\nvoid loop(){\r\n  \/\/ calculates color input\r\n  if (millis() - setPosTimer &gt;= 5000 &amp;&amp; millis() &gt;= 10000) {\r\n    uint16_t r, g, b, c;\r\n    tcs.getRawData(&amp;r, &amp;g, &amp;b, &amp;c);\r\n    float red, green, blue;\r\n    tcs.getRGB(&amp;red, &amp;green, &amp;blue);\r\n\r\n\r\n    red = red \/ 255;\r\n    green = green \/ 255; \r\n    blue = blue \/ 255;\r\n    \r\n    double h = rgb2hsv(red, green, blue).h;\r\n    int hue = int(h);\r\n    Serial.println(hue);\r\n\r\n    if (hue &gt;= 0 &amp;&amp; hue &lt; 15) {\r\n      strncpy(color, \"red\", 3);\r\n    } else if (hue &gt;= 15 &amp;&amp; hue &lt; 45){\r\n      strncpy(color, \"orange\", 6);\r\n    } else if (hue &gt;= 45 &amp;&amp; hue &lt; 75){\r\n      strncpy(color, \"yellow\", 6);\r\n    } else if (hue &gt;= 75 &amp;&amp; hue &lt; 150){\r\n      strncpy(color, \"green\", 5);\r\n    } else if (hue &gt;= 150 &amp;&amp; hue &lt; 200){\r\n      strncpy(color, \"cyan\", 4);\r\n    } else if (hue &gt;= 200 &amp;&amp; hue &lt; 255){\r\n      strncpy(color, \"blue\", 4);\r\n    } else if (hue &gt;= 255 &amp;&amp; hue &lt; 285){\r\n      strncpy(color, \"purple\", 6);\r\n    } else if (hue &gt;= 285 &amp;&amp; hue &lt; 315){\r\n      strncpy(color, \"pink\", 4);\r\n    } else if (hue &gt;= 315 &amp;&amp; hue &lt; 360){\r\n      strncpy(color, \"red\", 3);\r\n    } else {\r\n      strncpy(color, \"N\/A\", 3);\r\n    }\r\n    lcd.home();\r\n    lcd.print(\"Color: \");\r\n    lcd.print(color);\r\n    strncpy(color, \"          \", 10);\r\n\r\n    \/\/ moves stepper motor\r\n    int stepperTarget = map(hue, 0, 360, 0, 200) + calibPos;\r\n    Serial.print(\"Current pos and Target pos: \");\r\n    Serial.print(pos);\r\n    Serial.print(\", \");\r\n    Serial.println(stepperTarget);\r\n    myMotor.moveTo(stepperTarget);\r\n    pos = stepperTarget;\r\n    setPosTimer = millis();\r\n    lcd.setCursor(0, 1);\r\n    lcd.print(\"moving to: \");\r\n    lcd.print(stepperTarget);\r\n\r\n  }\r\n  \r\n  \/\/ Use button to calibrate without changing pos\r\n  if (digitalRead(buttonPin) == HIGH &amp;&amp; millis() - buttonTimer &gt;= 1000){\r\n    Serial.println(\"Press\");\r\n    calibPos += 20;\r\n    myMotor.moveTo(pos);\r\n    buttonTimer = millis();\r\n  }\r\n\r\n  \/\/ moves servo motor\r\n  if ( count % 100 == 0 ) {\r\n    int servPos = map(total\/100, 0, 1023, 10, 90);\r\n    Serial.println(servPos);\r\n    serv.write(servPos);\r\n    total = 0;\r\n  }\r\n  total += analogRead(A0);\r\n  count++;\r\n  myMotor.run();\r\n\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Color to Rotational Position Our double transducer took color as an input, transforming it into rotational position. The first part is the color sensor (at the top of&#8230;<\/p>\n","protected":false},"author":202,"featured_media":14025,"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\/f2021\/work\/wp-json\/wp\/v2\/posts\/13995"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/users\/202"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/comments?post=13995"}],"version-history":[{"count":7,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/posts\/13995\/revisions"}],"predecessor-version":[{"id":14091,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/posts\/13995\/revisions\/14091"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/media\/14025"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/media?parent=13995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/categories?post=13995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/tags?post=13995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}