{"id":15277,"date":"2022-03-16T02:30:30","date_gmt":"2022-03-16T06:30:30","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/?p=15277"},"modified":"2022-03-16T02:34:14","modified_gmt":"2022-03-16T06:34:14","slug":"project-2-smart-hat-with-rotatable-brim","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/project-2-smart-hat-with-rotatable-brim\/","title":{"rendered":"Smart Hat with Rotatable Brim"},"content":{"rendered":"<p>60223 Project 2 &#8211; David Wu<\/p>\n<p><strong>Smart Hat with Rotatable Brim<\/strong><\/p>\n<p>This smart hat can detect where the brightest light is (usually the sunlight), and rotate the brim to face that area- keeping you always in the shade.<\/p>\n<p><strong>Final Project Photos<\/strong><\/p>\n<div id=\"attachment_15601\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15601\" loading=\"lazy\" class=\"wp-image-15601 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7588-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7588-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7588-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7588-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7588-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7588-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7588-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7588-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15601\" class=\"wp-caption-text\">Final product with all components placed together.<\/p><\/div>\n<div id=\"attachment_15607\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15607\" loading=\"lazy\" class=\"wp-image-15607 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7596-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7596-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7596-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7596-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7596-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7596-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7596-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7596-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15607\" class=\"wp-caption-text\">Hat component contains velcro for mechanism attachment.<\/p><\/div>\n<div id=\"attachment_15603\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15603\" loading=\"lazy\" class=\"wp-image-15603 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7593-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7593-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7593-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7593-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7593-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7593-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7593-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7593-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15603\" class=\"wp-caption-text\">Stand-alone mechanism that sits on top of the hat.<\/p><\/div>\n<div id=\"attachment_15602\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15602\" loading=\"lazy\" class=\"wp-image-15602 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7592-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7592-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7592-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7592-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7592-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7592-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7592-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7592-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15602\" class=\"wp-caption-text\">Photoresistors are divided with cardboard to improve light detection accuracy.<\/p><\/div>\n<div id=\"attachment_15605\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15605\" loading=\"lazy\" class=\"wp-image-15605 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7595-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7595-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7595-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7595-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7595-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7595-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7595-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7595-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15605\" class=\"wp-caption-text\">Crushed and cut aluminum foil tubing was used as a support for the brim.<\/p><\/div>\n<p><strong>Video Demonstration<\/strong><\/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-15277-1\" width=\"620\" height=\"1102\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7591.MOV-1.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7591.MOV-1.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7591.MOV-1.mp4<\/a><\/video><\/div>\n<p>&nbsp;<\/p>\n<p><strong>Process Review<\/strong><\/p>\n<p>One key decision point was deciding how to detect the brightest light. There were many ideas here, mostly focused on where and how to arrange the photoresistors. To detect the brightest light, multiple photoresistors would be needed for comparison purposes. A ring of photoresistors attached around the hat (and as such, would be stationary) would offer a way to maintain a &#8220;grounded&#8221; reference, and as such, one would simply need to turn the motor to the position of the photoresistor with the brightest light detected. This idea was turned down due to the fact that it would require many wires running along the hat, resulting in hat discomfort, but also the fact that when the brim turned to the correct position, it would shade the photoresistor (and making it not detect the brightest light). This latter problem would cause a logical flaw, as it would therefore be impossibly to maintain the hat over the same spot, since the brightest spot would always end up shaded. Thus, the solution had to be that the photoresistors were located above the brim attachment, and that means they had to rotate as well. Putting a ring on top of the motor would work, but in effect, a smarter approach could be used; an entire ring would not be necessary, since we simply need a comparison of brightness. For example, as little as two photoresistors could work, since as long as one is brighter than the other, then we can focus on what\u00a0<em>direction<\/em> the motor needed to move to, and not exactly what <em>position<\/em> it needed to move to. As such, only an arc of photoresistors would be needed, though it is needed to note that having too few photoresistors could lead to inaccuracy, due to low amounts of data collection. Thus, the final product used four photoresistors, employing the smarter approach without sacrificing too much accuracy.<\/p>\n<div id=\"attachment_15615\" style=\"width: 1511px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15615\" loading=\"lazy\" class=\"wp-image-15615 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Light-Detection.png\" alt=\"\" width=\"1501\" height=\"1286\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Light-Detection.png 1501w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Light-Detection-300x257.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Light-Detection-1024x877.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Light-Detection-768x658.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Light-Detection-973x834.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Light-Detection-508x435.png 508w\" sizes=\"(max-width: 1501px) 100vw, 1501px\" \/><p id=\"caption-attachment-15615\" class=\"wp-caption-text\">These were initial plans and sketches as to what orientation of photoresistors would be best.<\/p><\/div>\n<p>Another key decision point was what motor to use to move the brim. The original approach was with a stepper motor, since it would allow for the most precise 360-degree controlled movement. However, after wiring and playing around with it for a bit, two obvious problems stood out: 1) the physical size and 2) the power source. The stepper motor was incredibly large and heavy, to the point where it could be unreasonable to belong on a head. Due to its hefty proportions and abilities, it also required a 12V power supply- which required an entire extra battery pack. Upon further consideration, I switched to the DC motor for the final product. A DC motor solved both problems- it was smaller and lighter, and it only needed a 6V power supply. The 6V power supply was crucial, since giving it 5V would be sufficient, and that meant it was possible to unify a power supply with the Arduino, who also used a 5V power supply. While DC motors would not be able to control exact position, this can be resolved using the smart method as aforementioned in the previous decision point- exact <em>position<\/em> does not matter; only <em>direction<\/em> does. Fortunately, changing the direction of a DC motor was incredibly simple; all that needed to be done was flipping the power and ground voltages of the two pins of the DC motor. The only potential issue was that DC motors had slightly less torque than a stepper motor, but after some testing, this proved to be negligible.<\/p>\n<div id=\"attachment_15610\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15610\" loading=\"lazy\" class=\"wp-image-15610 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4926-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4926-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4926-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4926-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4926-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4926-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4926-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4926-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4926-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15610\" class=\"wp-caption-text\">The large size of the stepper motor and extra battery pack caused orientating the mechanism to be difficult and overly bulky.<\/p><\/div>\n<p><strong>Process Images<\/strong><\/p>\n<div id=\"attachment_15611\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15611\" loading=\"lazy\" class=\"wp-image-15611 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4927-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4927-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4927-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4927-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4927-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4927-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4927-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4927-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4927-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15611\" class=\"wp-caption-text\">This is the first prototype of the mechanism- with stepper motor and large, extra battery pack.<\/p><\/div>\n<div id=\"attachment_15612\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15612\" loading=\"lazy\" class=\"wp-image-15612 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4932-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4932-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4932-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4932-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4932-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4932-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4932-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4932-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4932-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15612\" class=\"wp-caption-text\">This is an in-depth look at the circuitry involved, primarily focusing on the photoresistors and accompanying resistors.<\/p><\/div>\n<div id=\"attachment_15613\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15613\" loading=\"lazy\" class=\"wp-image-15613 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4962-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4962-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4962-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4962-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4962-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4962-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4962-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4962-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15613\" class=\"wp-caption-text\">This is initial experimentation as to what material to make the brim support out of.<\/p><\/div>\n<div class=\"mceTemp\"><\/div>\n<div id=\"attachment_15619\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15619\" loading=\"lazy\" class=\"wp-image-15619 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/NPKU5745-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/NPKU5745-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/NPKU5745-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/NPKU5745-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/NPKU5745-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/NPKU5745-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/NPKU5745-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/NPKU5745-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15619\" class=\"wp-caption-text\">Initial bundling of the electronics together showed promise of a small mechanism.<\/p><\/div>\n<div id=\"attachment_15614\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15614\" loading=\"lazy\" class=\"wp-image-15614 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4968-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4968-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4968-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4968-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4968-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4968-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4968-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4968-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_4968-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15614\" class=\"wp-caption-text\">Everything in the mechanism of the final version is combined- electronics, DC motor, and brim.<\/p><\/div>\n<div id=\"attachment_15608\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15608\" loading=\"lazy\" class=\"wp-image-15608 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7597-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7597-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7597-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7597-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7597-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7597-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7597-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_7597-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15608\" class=\"wp-caption-text\">Adding a cardboard plating to the inside of the hat was one of many attempts to prevent the mechanism from tilting.<\/p><\/div>\n<p><strong>Discussion and Reflection<\/strong><\/p>\n<p>In general, this project proved to be quite a challenge, and as a result, was good, but not completely perfect. On the bright side (pun not intended), the overall mechanism of the hat worked- the motor rotated the brim towards the brightest light that was detected by the photoresistors. Coding had been relatively straightforward, especially due to the smart method of photoresistor tracking; all that was needed was several comparisons and changing the voltages as necessary.<\/p>\n<p>What failed was the very last step, when everything had to come together. The mechanism proved to be too unbalanced to be placed on the hat. While I had devised six different plans to combat this should it occur, none of them ended up working due to one fatal flaw: the roundness of my head. The original plan was that the hat portion would firmly be on the head, and the mechanism would just be attached to the top. The unfortunate truth was that the mechanism was simply too top-heavy, and the long axle coming out of the motor had a small pivot surface.\u00a0As such, several attempts to create a wider base for the long axle were made- however, any structure would have a flat surface, and that meant that it would tilt on my head&#8217;s roundness. Other attempts to use strong adhesives, like velcro and hot glue, to forcefully and stiffly attach it to the hat did not fully work; while the mechanism was firmly attached to the hat, it would still tilt due to the same original reasons. Cardboard\/wood underlays were placed under the cap to try and create a flatter surface on the head, but these did not work, since the underlays themselves would tilt due to my head&#8217;s roundness. I thought shifting the location of where the mechanism would be attached to the hat, with similar regards to the comment that I should &#8220;a<span style=\"font-weight: 400\">dd the velcro on the hat to the top center so its on the most \u201cflat\u201d surface of [my] head,&#8221; would work, but it turns out no area of my head was flat enough- there was always tilting.<\/span><\/p>\n<p>In retrospect, I should have tried more plans, and earlier as well; it was just particularly unfortunate that it was the last step where everything failed. In general, what I managed to do successfully had gone rather smoothly- everything that I struggled in was due to a lack of knowledge. For example, this project affirmed to me that coding-wise, I should not have much problems; while Arduino does have new syntax I still need to learn, it should not be a major issue. I learned about motor differences and usages, how to use AutoCad, etc. There was much to learn, and still is much to learn. The best way to improve my skills is to constantly keep asking for advice on how to approach tasks, and learn as many new techniques as possible. All in all, if anything, learning that I did not learn enough to make this project work completely was a lesson that was valuably learned.<\/p>\n<p>Despite my shortcomings during this project, I do not plan on giving up on making the final product work as intended. I have wanted to build something like this for many years, and it would be silly, after all the advice and information I have learned, to end the project in its current state. I plan to further inquire for assistance regarding their advice, while proceeding further with some ideas of my own. For example, an initial naive idea would be to carve a piece of wood to fit my head&#8217;s roundness, while also providing a flat surface on the other side. I also particularly took interest in a comment that I could &#8220;w<span style=\"font-weight: 400\">ield the [motor&#8217;s] rod into an iron helmet,&#8221; since an iron helmet (or more probably some metal skeleton) would eliminate the need for a flat surface (they would be conjoined) and still have the shape for my head. <\/span>Whatever the final changes may be, I plan to complete this project, and come to school wearing it in all of its hilarious and quirky glory.<\/p>\n<p><strong>Functional Block Diagram and Schematic<\/strong><\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-15582\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Project-2-Schematic-1-1.jpg\" alt=\"\" width=\"1804\" height=\"2406\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Project-2-Schematic-1-1.jpg 1804w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Project-2-Schematic-1-1-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Project-2-Schematic-1-1-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Project-2-Schematic-1-1-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Project-2-Schematic-1-1-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Project-2-Schematic-1-1-973x1298.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Project-2-Schematic-1-1-508x678.jpg 508w\" sizes=\"(max-width: 1804px) 100vw, 1804px\" \/><\/p>\n<p><strong>Project Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/* Project Title: Smart Hat with Rotatable Brim\r\n * Creator: David Wu\r\n * \r\n * This code takes in the input of four photoresistors to \r\n * find the brightest light source, and then, if needed, \r\n * rotates the brim of the hat in that general direction \r\n * by flip-flopping the voltages on the pins of the DC motor.\r\n * The brim is centered between the second and third \r\n * photoresistors. The code is adaptable to left-right\r\n * orientation (physical implementation of the four photoresistors\r\n * does not matter as it just requires re-defining which \r\n * direction the brim will turn).\r\n * \r\n * Pin Mapping:\r\n * Photoresistor 1 : A0\r\n * Photoresistor 2 : A1\r\n * Photoresistor 3 : A2\r\n * Photoresistor 4 : A3\r\n * DC Pin 1        : 5\r\n * DC Pin 2        : 6 \r\n * \r\n *\/\r\n \r\nconst int DCPIN1 = 5; \/\/ DRV8833 B1 in\r\nconst int DCPIN2 = 6; \/\/ DRV8833 B2 in\r\nconst int PHOTOPIN1 = A0;\/\/ photoresistor input\r\nconst int PHOTOPIN2 = A1;\/\/ photoresistor input\r\nconst int PHOTOPIN3 = A2;\/\/ photoresistor input\r\nconst int PHOTOPIN4 = A3;\/\/ photoresistor input\r\nint timer = 0; \/\/ to slow down motor responsiveness\r\n\r\nvoid setup() {\r\n  pinMode(PHOTOPIN1, INPUT);\r\n  pinMode(PHOTOPIN2, INPUT);\r\n  pinMode(PHOTOPIN3, INPUT);\r\n  pinMode(PHOTOPIN4, INPUT);\r\n  pinMode(DCPIN1, OUTPUT);\r\n  pinMode(DCPIN2, OUTPUT);\r\n  Serial.begin(9600);\r\n}\r\n\r\nvoid loop() {\r\n  \/\/ prevent motor from switching too quickly and minimize jittering\r\n  if(millis() - timer &gt;= 500) {\r\n    \/\/ read photoresistor values (0 - 1023)\r\n    int bright1 = analogRead(PHOTOPIN1);\r\n    int bright2 = analogRead(PHOTOPIN2);\r\n    int bright3 = analogRead(PHOTOPIN3);\r\n    int bright4 = analogRead(PHOTOPIN4);\r\n\r\n    \/\/ calculate the brightest spot\r\n    int max12 = max(bright1, bright2);\r\n    int max34 = max(bright3, bright4);\r\n    int maxBright = max(max12, max34);\r\n\r\n    \/\/ if brightest is at center (where brim is)\r\n    if((bright2 == maxBright) &amp;&amp; (bright3 == maxBright)){\r\n      \/\/ don't move the motor\r\n      analogWrite(DCPIN1, 0);\r\n      analogWrite(DCPIN2, 0);\r\n    }\r\n    \/\/ if brightest is to the left\r\n    else if ((bright1 == maxBright) || (bright2 == maxBright)){\r\n      \/\/ rotate brim to the left\r\n      analogWrite(DCPIN1, 0);\r\n      analogWrite(DCPIN2, 128);\r\n    }\r\n    \/\/ if brightest is to the right\r\n    else{ \r\n      \/\/ rotate brim to the right\r\n      analogWrite(DCPIN1, 128);\r\n      analogWrite(DCPIN2, 0);\r\n    }\r\n    timer = millis();\r\n  }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>60223 Project 2 &#8211; David Wu Smart Hat with Rotatable Brim This smart hat can detect where the brightest light is (usually the sunlight), and rotate the brim&#8230;<\/p>\n","protected":false},"author":209,"featured_media":15601,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[89],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15277"}],"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\/209"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/comments?post=15277"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15277\/revisions"}],"predecessor-version":[{"id":15629,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15277\/revisions\/15629"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media\/15601"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media?parent=15277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/categories?post=15277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/tags?post=15277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}