{"id":15006,"date":"2022-02-16T10:00:32","date_gmt":"2022-02-16T15:00:32","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/?p=15006"},"modified":"2022-02-16T10:04:34","modified_gmt":"2022-02-16T15:04:34","slug":"double-transducer-y-axis-magnetic-field-to-wheel-of-color","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/double-transducer-y-axis-magnetic-field-to-wheel-of-color\/","title":{"rendered":"Double Transducer: Y-Axis Magnetic Field to Wheel of Color"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"wp-image-15013 aligncenter\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0323-scaled-e1644855203853.jpg\" alt=\"\" width=\"486\" height=\"321\" \/><\/p>\n<h1>Project I: Y-Axis Magnetic Field to Wheel of Color<\/h1>\n<h3>Images of Final Project<\/h3>\n<ol>\n<li>Overall photo for proportion and scale<\/li>\n<\/ol>\n<div id=\"attachment_15014\" style=\"width: 418px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15014\" loading=\"lazy\" class=\"wp-image-15014\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5590-scaled-e1644855376592.jpeg\" alt=\"\" width=\"408\" height=\"354\" \/><p id=\"caption-attachment-15014\" class=\"wp-caption-text\">Sumayya Syeda&#8217;s overall picture<\/p><\/div>\n<div id=\"attachment_15015\" style=\"width: 416px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15015\" loading=\"lazy\" class=\"wp-image-15015\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0324-scaled-e1644855357848.jpg\" alt=\"\" width=\"406\" height=\"390\" \/><p id=\"caption-attachment-15015\" class=\"wp-caption-text\">Tiana Porwanto&#8217;s overall picture<\/p><\/div>\n<p>2. Details of part to highlight<\/p>\n<div id=\"attachment_15016\" style=\"width: 416px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15016\" loading=\"lazy\" class=\"wp-image-15016 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0317-scaled-e1644856343766.jpg\" alt=\"\" width=\"406\" height=\"418\" \/><p id=\"caption-attachment-15016\" class=\"wp-caption-text\">This is the 3-axis compass\/magnetometer. It is attached to a a breadboard which is elevated using paddlepop sticks. Adjusting to the group who acts as our input, we are only reading magnetic field in the Y-axis.<\/p><\/div>\n<div id=\"attachment_15017\" style=\"width: 418px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15017\" loading=\"lazy\" class=\"wp-image-15017 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0318-scaled-e1644855850390.jpg\" alt=\"\" width=\"408\" height=\"502\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0318-scaled-e1644855850390.jpg 979w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0318-scaled-e1644855850390-244x300.jpg 244w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0318-scaled-e1644855850390-833x1024.jpg 833w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0318-scaled-e1644855850390-768x944.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0318-scaled-e1644855850390-973x1196.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0318-scaled-e1644855850390-508x624.jpg 508w\" sizes=\"(max-width: 408px) 100vw, 408px\" \/><p id=\"caption-attachment-15017\" class=\"wp-caption-text\">This is Tiana&#8217;s LED and photoresistor. Tiana&#8217;s photoresistor is poorly soldered to the protoboard, which leads to problems such as the code not running through the circuit. The green LED is directly touching the photoresistor to make sure the photoresistor gets the light.<\/p><\/div>\n<div id=\"attachment_15018\" style=\"width: 420px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15018\" loading=\"lazy\" class=\"wp-image-15018 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0319-scaled.jpg\" alt=\"\" width=\"410\" height=\"547\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0319-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0319-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0319-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0319-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0319-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0319-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_0319-508x677.jpg 508w\" sizes=\"(max-width: 410px) 100vw, 410px\" \/><p id=\"caption-attachment-15018\" class=\"wp-caption-text\">This is our wheel of color with a servomotor as its pointer. The servomotor is supposed to move its handle and choose a color based on the light received by the photoresistor.<\/p><\/div>\n<div id=\"attachment_15019\" style=\"width: 416px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15019\" loading=\"lazy\" class=\"wp-image-15019 \" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5589-scaled.jpeg\" alt=\"\" width=\"406\" height=\"541\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5589-scaled.jpeg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5589-225x300.jpeg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5589-768x1024.jpeg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5589-1152x1536.jpeg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5589-1536x2048.jpeg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5589-973x1297.jpeg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5589-508x677.jpeg 508w\" sizes=\"(max-width: 406px) 100vw, 406px\" \/><p id=\"caption-attachment-15019\" class=\"wp-caption-text\">This is Sumayya&#8217;s LED and photoresistor attached to the protoboard. Her pieces are nicely soldered, creating a great connection through the circuit. Her photoresistor is not touching the LED, but it does face the LED directly.<\/p><\/div>\n<p>3. Brief movie in mp4 format<\/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-15006-1\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5635.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5635.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/IMG_5635.mp4<\/a><\/video><\/div>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-15006-2\" width=\"620\" height=\"388\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Tiana-Double-Transducer-Video-1.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Tiana-Double-Transducer-Video-1.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Tiana-Double-Transducer-Video-1.mp4<\/a><\/video><\/div>\n<h3>Simple Narrative Description<\/h3>\n<p><span style=\"font-weight: 400\">This double transducer measures a magnet\u2019s strength. Then it converts that measurement to a brightness level for an LED. The LED is brighter when there is more strength, and dimmer when there is less. Then a photoresistor measures how bright the LED is and sends that information to the servo. The servo reads how bright the LED is from the photoresistor and moves its arm accordingly to point to a color on the color wheel.\u00a0<\/span><\/p>\n<h3>Four Progress Images<\/h3>\n<div id=\"attachment_15021\" style=\"width: 394px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15021\" loading=\"lazy\" class=\"size-full wp-image-15021\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-1.jpeg\" alt=\"\" width=\"384\" height=\"512\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-1.jpeg 384w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-1-225x300.jpeg 225w\" sizes=\"(max-width: 384px) 100vw, 384px\" \/><p id=\"caption-attachment-15021\" class=\"wp-caption-text\">This is Sumayya&#8217;s rough wiring before soldering or gluing any components. It is the rough structure Sumayya had before finalizing the placements of all my sensors.<\/p><\/div>\n<div id=\"attachment_15022\" style=\"width: 394px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15022\" loading=\"lazy\" class=\"wp-image-15022 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-2.jpeg\" alt=\"\" width=\"384\" height=\"512\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-2.jpeg 384w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-2-225x300.jpeg 225w\" sizes=\"(max-width: 384px) 100vw, 384px\" \/><p id=\"caption-attachment-15022\" class=\"wp-caption-text\">Sumayya realized she had not added a photoresistor to her circuit. This is the image before she redid her soldering of the LED and photoresistor components.<\/p><\/div>\n<div id=\"attachment_15023\" style=\"width: 394px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15023\" loading=\"lazy\" class=\"wp-image-15023 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-3.jpeg\" alt=\"\" width=\"384\" height=\"512\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-3.jpeg 384w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-3-225x300.jpeg 225w\" sizes=\"(max-width: 384px) 100vw, 384px\" \/><p id=\"caption-attachment-15023\" class=\"wp-caption-text\">This is Tiana&#8217;s circuit before she soldered or glued any components to the cardboard. At this point, she was still testing whether the code would work on her circuit.<\/p><\/div>\n<div id=\"attachment_15024\" style=\"width: 394px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15024\" loading=\"lazy\" class=\"wp-image-15024 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-4.jpeg\" alt=\"\" width=\"384\" height=\"512\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-4.jpeg 384w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Progress-Image-4-225x300.jpeg 225w\" sizes=\"(max-width: 384px) 100vw, 384px\" \/><p id=\"caption-attachment-15024\" class=\"wp-caption-text\">Reading the grading rubric, Tiana realized she needed to solder her middle step (LED -&gt; photoresistor). Professor recommended she use a protoboard and solder both LED and photoresistor to it. This is a picture before the soldering process.<\/p><\/div>\n<h3>Discussion<\/h3>\n<p><span style=\"font-weight: 400\">While planning for the project, our team decided on a very simple concept: a servomotor pointing a color on a color wheel. However, we later realized that this project was more complicated than planned. It took us some time to understand how the components should be wired and placed on the board while maintaining its aesthetics. We also learned that soldering was hard, since we needed to make sure we had the right circuit before permanently attaching it. This whole process helped us understand the importance of planning and double checking schematics before diving into the hands on work.<\/span><\/p>\n<p><span style=\"font-weight: 400\">While dealing with the software of the project, we realized that we could not code according to theory. For example, mapping did not work great when we inserted min and max value as the input. We went through a lot of trials and errors to understand which interval best suited the mapping. We also realized that hardware issues can happen during the software process. Some pieces may be knocked over and lose their connection, leading us to think it was our software that had problems. By the end of the project, we were still proud of our accomplishments and learned a lot in a short period of time.\u00a0<\/span><\/p>\n<h3>Functional Block Diagram and Schematic<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-15035\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Double-Transducer-Functional-Block.svg\" alt=\"\" width=\"1368\" height=\"433\" \/> <img loading=\"lazy\" class=\"alignnone size-full wp-image-15036\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/02\/Double-Transducer-Functional-Scheme.svg\" alt=\"\" width=\"1041\" height=\"931\" \/><\/h3>\n<h3>Code Submission<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/**\r\n * @Title: Magnetometer to Color Double Transducer\r\n * @author: Sumayya Syeda\r\n * @co-author: Tiana Porwanto\r\n * \r\n * This program measures the magnetic field measured by the QMC5883LCompass to turn a servo motor a certain angle \r\n * and point at a certain color\r\n * The magnetic measurement sets the brightness of an LED. This brightness is measured by a photoresistor. The reading \r\n * of the photoresistor sets the angle of the servo motor. \r\n *\/\r\n#include &lt;QMC5883LCompass.h&gt;\r\n#include &lt;Wire.h&gt;\r\n#include &lt;LiquidCrystal_I2C.h&gt;\r\n#include &lt;Servo.h&gt;\r\n\r\n\r\nQMC5883LCompass Magnet;\r\nLiquidCrystal_I2C lcd(0x27, 20, 4);\r\nServo servo;\r\n\r\nint LED_PIN = 5;\r\nint PHOTORESISTOR_PIN = 3;\r\nint SERVO_PIN = 6;\r\n\r\n\r\nvoid setup() {\r\n  pinMode (LED_PIN, OUTPUT);\r\n  pinMode (PHOTORESISTOR_PIN, INPUT);\r\n  \r\n  Magnet.init();\r\n  lcd.init();\r\n\r\n  servo.attach(SERVO_PIN);\r\n\r\n  lcd.backlight();\r\n  lcd.home();\r\n\r\n  lcd.setCursor(16,  .0);\r\n\r\n  Serial.begin(9600);\r\n  lcd.println(\"Program Started!\");\r\n}\r\n\r\n\r\nvoid loop() {\r\n  \/\/ put your main code here, to run repeatedly:\r\n\r\n  int avg_m_field\r\n  int brightness;\r\n  int lightVal;\r\n  int servoVal;\r\n  lcd.setCursor(0, 0);\r\n\r\n\r\n  Magnet.read();\r\n  delay(100);\r\n\r\n  \/\/read magnetic field \r\n  int y = Magnet.getY();\r\n  avg_m_field = abs(y);\r\n  int lcd_mag = map(avg_m_field, 1300, 10000, 0, 99);\r\n  lcd.print(\"i:\");\r\n  lcd.print(abs(lcd_mag));\r\n\r\n\r\n  \/\/map magnetic field to led brightness\r\n  brightness = map(avg_m_field, 1200, 10000, 0, 255);\r\n  int lcd_brightness = map(brightness, 0, 255, 0, 99);\r\n  lcd.setCursor(9, 0);\r\n  lcd.print(\"m1:\");\r\n  lcd.print(lcd_brightness);\r\n  analogWrite(LED_PIN, brightness);\r\n\r\n  \/\/photoresistor reads led brightness\r\n  lightVal = analogRead(PHOTORESISTOR_PIN);\r\n  int lcd_lightVal = map(lightVal, 60, 100, 0, 99);\r\n  lcd.setCursor(0, 1);\r\n  lcd.print(\"m2:\");\r\n  lcd.print(lcd_lightVal);\r\n\r\n  \/\/servo maps photoresistor values to servo values\r\n  servoVal = map(lightVal, 60, 100, 10, 170);\r\n  lcd.setCursor(8, 1);\r\n  int lcd_servo = map(servoVal, 10, 170, 0, 99);\r\n  lcd.print(\"o:\");\r\n  lcd.print(lcd_servo);\r\n  servo.write(servoVal);\r\n\r\n  delay(500);\r\n  lcd.clear();\r\n\r\n\r\n\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Project I: Y-Axis Magnetic Field to Wheel of Color Images of Final Project Overall photo for proportion and scale 2. Details of part to highlight 3. Brief movie&#8230;<\/p>\n","protected":false},"author":211,"featured_media":15013,"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\/s2022\/work\/wp-json\/wp\/v2\/posts\/15006"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/users\/211"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/comments?post=15006"}],"version-history":[{"count":6,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15006\/revisions"}],"predecessor-version":[{"id":15065,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15006\/revisions\/15065"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media\/15013"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media?parent=15006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/categories?post=15006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/tags?post=15006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}