{"id":17171,"date":"2023-02-14T17:19:37","date_gmt":"2023-02-14T22:19:37","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/?p=17171"},"modified":"2023-02-14T23:59:30","modified_gmt":"2023-02-15T04:59:30","slug":"project-1-double-transducer-temperature-to-fan-speed","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/project-1-double-transducer-temperature-to-fan-speed\/","title":{"rendered":"Double Transducer &#8211; Temperature to Fan Speed."},"content":{"rendered":"<p>Angie Wang, Stanley Ip, Michelle Liu<\/p>\n<div id=\"attachment_17310\" style=\"width: 2570px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-17310\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17310 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3229-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3229-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3229-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3229-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3229-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3229-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3229-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3229-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3229-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-17310\" class=\"wp-caption-text\">Top view of Stanley&#8217;s Double Transducer. Thermistor (left), fan (right)<\/p><\/div>\n<div id=\"attachment_17442\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-17442\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17442 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3117-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3117-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3117-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3117-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3117-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3117-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3117-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3117-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3117-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-17442\" class=\"wp-caption-text\">Top view of Michelle&#8217;s Double Transducer. Fan (left), thermistor (right).<\/p><\/div>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-17453\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_5693-2-254x300.jpg\" alt=\"\" width=\"254\" height=\"300\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_5693-2-254x300.jpg 254w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_5693-2-867x1024.jpg 867w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_5693-2-768x907.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_5693-2-1301x1536.jpg 1301w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_5693-2-1734x2048.jpg 1734w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_5693-2-973x1149.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_5693-2-508x600.jpg 508w\" sizes=\"(max-width: 254px) 100vw, 254px\" \/><\/p>\n<p>Top view of Angie&#8217;s Double Transducer. Thermistor(Middle-left, labeled as &#8220;INPUT&#8221;), Fan(Top-right, labeled as &#8220;OUTPUT&#8221;)<\/p>\n<div id=\"attachment_17311\" style=\"width: 2570px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-17311\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17311 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3230-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3230-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3230-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3230-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3230-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3230-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3230-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3230-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3230-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-17311\" class=\"wp-caption-text\">Adafruit color sensor secured directly above color wheel, which is spun by a stepper motor.<\/p><\/div>\n<div id=\"attachment_17312\" style=\"width: 1930px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-17312\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17312 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3226-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3226-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3226-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3226-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3226-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3226-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3226-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3226-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-17312\" class=\"wp-caption-text\">Another angle of the Adafruit color sensor secured above the color wheel and overview of some of the wiring we did to connect the steps.<\/p><\/div>\n<div id=\"attachment_17317\" style=\"width: 2570px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-17317\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17317 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3234-1-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3234-1-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3234-1-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3234-1-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3234-1-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3234-1-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3234-1-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3234-1-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3234-1-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-17317\" class=\"wp-caption-text\">Close up of the fan and LED setup.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p><strong>Final Working Model:<\/strong><\/p>\n<p>Stanley<\/p>\n<p><iframe loading=\"lazy\" title=\"Double Transducer - Temperature to Air Speed - Stanley Ip\" width=\"620\" height=\"349\" src=\"https:\/\/www.youtube.com\/embed\/CRgPd6X-TrQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/p>\n<p>Michelle<\/p>\n<p><iframe loading=\"lazy\" title=\"Double Transducer - Temperature to Color to Wind Speed\" width=\"620\" height=\"349\" src=\"https:\/\/www.youtube.com\/embed\/IfFwAyhJtMI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/p>\n<p><strong>Narrative Description:<\/strong><\/p>\n<p>The thermistor picks up on the temperature being emitted, and based on how high or low the temperature is, the Arduino Uno will determine how much to rotate a stepper motor. A color wheel is attached to the stepper motor, and an RGB sensor will detect the hue rotated in front of it. This hue then determines the wind speed.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Process:<\/strong><\/p>\n<div id=\"attachment_17315\" style=\"width: 1189px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-17315\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17315 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/stepper-motor-with-wheel-spinning.png\" alt=\"A hand holding the adafruit sensor next to a color wheel, propped up on a stepper motor.\" width=\"1179\" height=\"591\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/stepper-motor-with-wheel-spinning.png 1179w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/stepper-motor-with-wheel-spinning-300x150.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/stepper-motor-with-wheel-spinning-1024x513.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/stepper-motor-with-wheel-spinning-768x385.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/stepper-motor-with-wheel-spinning-973x488.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/stepper-motor-with-wheel-spinning-508x255.png 508w\" sizes=\"(max-width: 1179px) 100vw, 1179px\" \/><p id=\"caption-attachment-17315\" class=\"wp-caption-text\">Testing the Adafruit sensor and stepper motor to make sure these middle step components work reliably. &#8211; Stanley<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_17316\" style=\"width: 915px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-17316\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17316\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/hue-.png\" alt=\"\" width=\"905\" height=\"603\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/hue-.png 809w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/hue--300x200.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/hue--768x512.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/hue--508x338.png 508w\" sizes=\"(max-width: 905px) 100vw, 905px\" \/><p id=\"caption-attachment-17316\" class=\"wp-caption-text\">Getting the color sensor to pick up hue from the color wheel. As the color wheel spins, the hue value is recorded and is represented by the graph on screen. &#8211; Stanley<\/p><\/div>\n<p>&nbsp;<\/p>\n<div style=\"width: 620px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-17171-1\" width=\"620\" height=\"1102\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3029__1__AdobeExpress.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3029__1__AdobeExpress.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3029__1__AdobeExpress.mp4<\/a><\/video><\/div>\n<p>Getting the fan to respond to hue. A higher hue value (blues, purples) corresponds to higher fan speed, and lower hue values (red) corresponds to lower fan speed. &#8211; Michelle<\/p>\n<p>&nbsp;<\/p>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-17171-2\" width=\"620\" height=\"1102\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3036__1__MOV_AdobeExpress.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3036__1__MOV_AdobeExpress.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/IMG_3036__1__MOV_AdobeExpress.mp4<\/a><\/video><\/div>\n<p>Putting it all together (stepper motor, color wheel, fan) &#8211; Michelle<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Discussion:<\/strong><\/p>\n<p><span style=\"font-weight: 400\">From the beginning of the project, we didn\u2019t expect that our direction of going from a temperature input, to color, and fan speed would be technically challenging to execute. In particular, there were a few external things we had to learn, from learning how to use a MOSFET to control fan speed, to using a driver for the stepper motor, etc. We worked through this by taking the time to understand each component individually first &#8211; their capabilities, how the hardware itself works, how to speak to it through code, etc. and that helped us get a holistic idea of how we can get each component to communicate with each other.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Needless to say, there was a lot of debugging in our process. With so many new components and systems, it was difficult to pinpoint exactly which part was going wrong &#8211; whether it was the software, weak connections, or just a single wire plugged incorrectly. Oftentimes, we would mess with the code and wiring a lot just to find that the breadboard was faulty. Towards the end, we learned to use software workarounds for hardware problems. For example, with the RGB sensor, it was difficult to figure out a way to physically set the stepper motor such that the low temperature corresponds to the red part (low hue value) of the color wheel. Instead, we wrote a function to rotate and calibrate the color wheel, so that a lower temperature always corresponds to red, and a higher temperature always corresponds to purple.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">In the end, we are glad that we followed through with the idea, using these different dimensions (temperature, hue, fan speed) in a novel yet cohesive way, and it was definitely a very productive experience in learning how to work with hardware and software simultaneously and creatively.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Block Diagram &amp; Schematic:<\/strong><\/p>\n<p><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/project-1-double-transducer-temperature-to-fan-speed\/project-1-idea-1-functional-diagram\/\" rel=\"attachment wp-att-17339\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-17339 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/Project-1-Idea-1-Functional-Diagram.jpg\" alt=\"\" width=\"947\" height=\"377\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/Project-1-Idea-1-Functional-Diagram.jpg 947w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/Project-1-Idea-1-Functional-Diagram-300x119.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/Project-1-Idea-1-Functional-Diagram-768x306.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/Project-1-Idea-1-Functional-Diagram-508x202.jpg 508w\" sizes=\"(max-width: 947px) 100vw, 947px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/project-1-double-transducer-temperature-to-fan-speed\/double-transducer-schematic\/\" rel=\"attachment wp-att-17338\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-17338 aligncenter\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/double-transducer-schematic.jpg\" alt=\"\" width=\"1451\" height=\"941\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/double-transducer-schematic.jpg 1451w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/double-transducer-schematic-300x195.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/double-transducer-schematic-1024x664.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/double-transducer-schematic-768x498.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/double-transducer-schematic-973x631.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/02\/double-transducer-schematic-508x329.jpg 508w\" sizes=\"(max-width: 1451px) 100vw, 1451px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/*\r\n* TEMPERATURE &gt; COLOR &gt; FAN SPEED DOUBLE TRANSDUCER\r\n* Michelle Liu, Stanley Ip, Angie Wang\r\n* \r\n* The thermistor picks up on the temperature being emitted, and based on how high or \r\n* low the temperature is, the Arduino Uno will determine how much to rotate a stepper motor.\r\n* A color wheel is attached to the stepper motor, and an RGB sensor will detect the hue\r\n* rotated in front of it. This hue then determines the fan speed.\r\n* \r\n* Pin Map:\r\nvariable name | mode | pin | description\r\n-----------------------------------------------\r\nFAN_PIN | output | 10 | controls fan speed\r\nSTEP_PIN | output | 2 | stepper motor: sets stepper position\r\nDIR_PIN | output | 3 | stepper motor: sets stepper direction\r\nTHERMO_PIN | output | A0 | thermistor: reads in resistance from the thermistor\r\n* \r\n* Credits:\r\n* RGB sensor code referenced from the Adafruit TCS34725 breakout library example\r\n* code: https:\/\/learn.adafruit.com\/adafruit-color-sensors\/arduino-code\r\n* \r\n* Algorithm for converting RGB values to hue values referenced from\r\n* https:\/\/www.geeksforgeeks.org\/program-change-rgb-color-model-hsv-color-model\/\r\n* \r\n* Stepper motor code referenced from the course website:\r\n* https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/tutorials\/stepper\r\n* \r\n* LCD display code referenced from the course website: \r\n* https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/tutorials\/I2C-lcd\r\n*\/\r\n\r\n\r\n#include &lt;Wire.h&gt;\r\n#include \"Adafruit_TCS34725.h\" \/\/ ADAFruit TCS34725 driver for ADAFruit TCS34725 RGB Color Sensor by Adafruit\r\n#include &lt;AccelStepper.h&gt; \/\/ AccelStepper stepper motor driver by Mike McCauley\r\n#include &lt;LiquidCrystal_I2C.h&gt; \/\/ LiquidCrystal I2C LCD display driver by Frank de Brabander\r\n\r\nLiquidCrystal_I2C screen(0x27, 16, 2);\r\n\r\nAdafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_614MS, TCS34725_GAIN_1X);\r\n\r\n\/\/ WIRING\r\nconst int FAN_PIN = 3;\r\nconst int STEP_PIN = 8;\r\nconst int DIR_PIN = 9;\r\nconst int THERMO_PIN = A0;\r\nconst int FAN_START_SPEED = 0;\r\n\r\nAccelStepper myMotor(1, STEP_PIN, DIR_PIN);\r\n\r\nint pos = 800; \/\/ variable to store motor position instruction\r\nint fanSpeed = 0;\r\nint dispDelay = 0;\r\n\r\nvoid setup(void) {\r\n  screen.init();\r\n  Serial.begin(9600);\r\n\r\n\/\/ LCD DISPLAY SETUP\r\n\r\n  screen.backlight();\r\n  screen.home();\r\n\r\n\/\/ RGB SENSOR SETUP\r\n\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\/\/ STEPPER MOTOR SETUP\r\n\r\n  myMotor.setMaxSpeed(1000); \/\/ measured in steps per second\r\n  myMotor.setAcceleration(500); \/\/ measured in steps per second squared\r\n\r\n  initializeMotorPos();\r\n\r\n  pinMode(FAN_PIN, OUTPUT);\r\n  pinMode(THERMO_PIN, INPUT);\r\n  analogWrite(FAN_PIN, FAN_START_SPEED);\r\n\r\n}\r\n\r\n\/\/ HUE ALGORITHM\r\n\/\/ Algorithm from https:\/\/www.geeksforgeeks.org\/program-change-rgb-color-model-hsv-color-model\/\r\n\/\/ Range: 0 (red) - 360 (violet)\r\ndouble calculateHue(uint16_t r, uint16_t g, uint16_t b) {\r\n  double rDepth = r \/ 65535.0;\r\n  double gDepth = g \/ 65535.0;\r\n  double bDepth = b \/ 65535.0;\r\n\r\n  double rgbMax = max(max(gDepth, bDepth), rDepth); \/\/ maximum of r, g, b\r\n  double rgbMin = min(min(gDepth, bDepth), rDepth); \/\/ minimum of r, g, b\r\n\r\n  double rgbDiff = rgbMax - rgbMin; \/\/ diff of cmax and cmin.\r\n\r\n  if (rgbDiff == 0) {\r\n    return 0.0;\r\n  } else if (rgbMax == rDepth) {\r\n    return fmod(60.0 * ((gDepth - bDepth) \/ rgbDiff) + 360.0, 360);\r\n  }\r\n  else if (rgbMax == gDepth) {\r\n    return fmod(60 * ((bDepth - rDepth) \/ rgbDiff) + 120, 360);\r\n  } else {\r\n    return fmod(60 * ((rDepth - gDepth) \/ rgbDiff) + 240, 360);\r\n  }\r\n}\r\n\r\n\/\/ Reads RGB sensor data without introducing a delay like the built-in function does\r\nvoid getRawData_noDelay(uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c)\r\n{\r\n  *c = tcs.read16(TCS34725_CDATAL);\r\n  *r = tcs.read16(TCS34725_RDATAL);\r\n  *g = tcs.read16(TCS34725_GDATAL);\r\n  *b = tcs.read16(TCS34725_BDATAL);\r\n}\r\n\r\n\/\/ initialize motor pos to approximately red\r\nvoid initializeMotorPos() {\r\n  uint16_t r, g, b, c, colorTemp, lux;\r\n\r\n  getRawData_noDelay(&amp;r, &amp;g, &amp;b, &amp;c);\r\n  int hue = (int)calculateHue(r, g, b);\r\n\r\n\/\/ rotate the stepper motor by 1 degree until the hue reaches a value close to red\r\n  while (hue &gt; 15) {\r\n    getRawData_noDelay(&amp;r, &amp;g, &amp;b, &amp;c);\r\n    hue = (int)calculateHue(r, g, b);\r\n    myMotor.move(1);\r\n    myMotor.run();\r\n  }\r\n  Serial.print(\"RED FOUND: \");\r\n  Serial.println(myMotor.currentPosition());\r\n  myMotor.setCurrentPosition(0);\r\n}\r\n\r\n\/\/ debugging helper function for printing values with their labels\r\nvoid p(String label, int val) {\r\n  Serial.print(label + \": \"); Serial.print(val, DEC); Serial.print(\" \");\r\n  Serial.println(\" \");\r\n}\r\n\r\nvoid displayVal(String c, int i) {\r\n  screen.print(c);\r\n  screen.print(\":\");\r\n  screen.print(i &lt; 10 ? \"0\" : \"\");\r\n  screen.print(i &lt; 10 ? \"0\" : \"\");\r\n  screen.print(i);\r\n}\r\n\r\n\/*\r\n   i = input, iMax = input upper range\r\n   m = middle-step actuator value, mMax = middle-step actuator value upper range\r\n   s = middle-step sensor value, mMax = middle-step sensor value upper range\r\n   o = output, oMax = middle-step actuator value upper range\r\n*\/\r\n\/\/ helper function for displaying values on the LCD screen\r\nvoid displayLCD(int i, int iMax, int m, int mMax, int s, int sMax, int o, int oMax) {\r\n  int iNorm = map(i, 0, iMax, 0, 99);\r\n  int mNorm = map(m, 0, mMax, 0, 99);\r\n  int sNorm = map(s, 0, sMax, 0, 99);\r\n  int oNorm = map(o, 0, oMax, 0, 99);\r\n\r\n  displayVal(\"i\", iNorm);\r\n  screen.print(\"  \");\r\n\r\n  displayVal(\"  m\", mNorm);\r\n\r\n  screen.setCursor(1, 6);\r\n\r\n  displayVal(\"s\", sNorm);\r\n  screen.print(\"  \");\r\n\r\n  displayVal(\"  o\", oNorm);\r\n\r\n   screen.print(\"      \");\r\n\r\n  if (dispDelay &gt; 100) {\r\n    dispDelay = 0;\r\n    screen.clear();\r\n  }\r\n}\r\n\r\nvoid loop() {\r\n  int thermoVal = analogRead(THERMO_PIN);\r\n\r\n  pos = map(thermoVal, 450, 600, 0, 200);\r\n\r\n  myMotor.moveTo(-pos); \/\/ and tell the motor to go there\r\n  myMotor.run(); \/\/ call this function as often as possible\r\n\r\n  uint16_t r, g, b, c, colorTemp, lux;\r\n\r\n  getRawData_noDelay(&amp;r, &amp;g, &amp;b, &amp;c);\r\n  int hue = (int)calculateHue(r, g, b);\r\n\r\n  fanSpeed = map(hue, 0, 360, FAN_START_SPEED, 255);\r\n\r\n  analogWrite(FAN_PIN, fanSpeed);\r\n\r\n  displayLCD(thermoVal, 1023, pos, 400, hue, 360, fanSpeed, 255);\r\n\r\n  dispDelay += 1;\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Angie Wang, Stanley Ip, Michelle Liu Top view of Angie&#8217;s Double Transducer. Thermistor(Middle-left, labeled as &#8220;INPUT&#8221;), Fan(Top-right, labeled as &#8220;OUTPUT&#8221;) &nbsp; Final Working Model: Stanley Michelle Narrative Description:&#8230;<\/p>\n","protected":false},"author":41,"featured_media":17309,"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\/s2023\/work\/wp-json\/wp\/v2\/posts\/17171"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/comments?post=17171"}],"version-history":[{"count":18,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/posts\/17171\/revisions"}],"predecessor-version":[{"id":17455,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/posts\/17171\/revisions\/17455"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/media\/17309"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/media?parent=17171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/categories?post=17171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/tags?post=17171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}