{"id":13146,"date":"2021-04-09T16:43:33","date_gmt":"2021-04-09T20:43:33","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/?p=13146"},"modified":"2021-04-09T17:16:50","modified_gmt":"2021-04-09T21:16:50","slug":"screen-distance-repellant","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/screen-distance-repellant\/","title":{"rendered":"Screen Distance Repellant"},"content":{"rendered":"<p><span style=\"font-weight: 400\">A servo-activated can of compressed air quickly teaches you to keep your distance from a monitor.<\/span><\/p>\n<h3><strong>Video in Action:<\/strong><\/h3>\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-13146-1\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1431.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1431.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1431.mp4<\/a><\/video><\/div>\n<h3><b>Detail Shots:<\/b><\/h3>\n<div id=\"attachment_13155\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13155\" loading=\"lazy\" class=\"wp-image-13155 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1426-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1426-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1426-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1426-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1426-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1426-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1426-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1426-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-13155\" class=\"wp-caption-text\">Top view.<\/p><\/div>\n<div id=\"attachment_13156\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13156\" loading=\"lazy\" class=\"wp-image-13156 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1478-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1478-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1478-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1478-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1478-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1478-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1478-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1478-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-13156\" class=\"wp-caption-text\">Closeup of servo arm and air duster trigger.<\/p><\/div>\n<div id=\"attachment_13157\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13157\" loading=\"lazy\" class=\"wp-image-13157 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1480-768x1024.jpg\" alt=\"\" width=\"620\" height=\"827\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1480-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1480-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1480-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1480-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1480-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1480-508x677.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1480-scaled.jpg 1920w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-13157\" class=\"wp-caption-text\">The Arduino inside the case.<\/p><\/div>\n<h3><strong>Use:<\/strong><\/h3>\n<div id=\"attachment_13159\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13159\" loading=\"lazy\" class=\"wp-image-13159 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-13159\" class=\"wp-caption-text\">This screen distance repellant is meant to be mounted on a larger monitor. A laptop also works, but not as well.<\/p><\/div>\n<p><img loading=\"lazy\" class=\"alignnone size-large wp-image-13160\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1428-768x1024.jpg\" alt=\"\" width=\"620\" height=\"827\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1428-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1428-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1428-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1428-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1428-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1428-508x677.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1428-scaled.jpg 1920w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<h3><strong>Overall Process Pictures:<\/strong><\/h3>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-13146-2\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1393.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1393.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1393.mp4<\/a><\/video><\/div>\n<p>In the above test, I decided to go with the time-of-flight sensor over the ultrasonic ranger, since a tilted object was less likely to create inaccurate readings.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-large wp-image-13162\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/download_device_resize_jpg.jpeg\" alt=\"\" width=\"620\" height=\"899\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/download_device_resize_jpg.jpeg 706w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/download_device_resize_jpg-207x300.jpeg 207w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/download_device_resize_jpg-508x737.jpeg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>To design the mount, I started with sketches of how the different electronic parts could be mounted to the spray can.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-13161\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/cad-model.png\" alt=\"\" width=\"954\" height=\"790\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/cad-model.png 954w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/cad-model-300x248.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/cad-model-768x636.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/cad-model-508x421.png 508w\" sizes=\"(max-width: 954px) 100vw, 954px\" \/><\/p>\n<p>I modeled an Arduino case and servo \/ can mount in Fusion 360.<\/p>\n<h3><strong>Decision Points:<\/strong><\/h3>\n<p><strong>1) Switch from delay() to millis() timing:<\/strong><\/p>\n<div id=\"attachment_13164\" style=\"width: 2058px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13164\" loading=\"lazy\" class=\"wp-image-13164 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/millis-and-delay-comparison.jpg\" alt=\"\" width=\"2048\" height=\"903\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/millis-and-delay-comparison.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/millis-and-delay-comparison-300x132.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/millis-and-delay-comparison-1024x452.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/millis-and-delay-comparison-768x339.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/millis-and-delay-comparison-1536x677.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/millis-and-delay-comparison-973x429.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/millis-and-delay-comparison-508x224.jpg 508w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><p id=\"caption-attachment-13164\" class=\"wp-caption-text\">millis() version on left, delay() version on right.<\/p><\/div>\n<p><span style=\"font-weight: 400\">Originally, I had written the code to function using delays. This meant that every time the servo activated, there was a half second delay where the TOF sensor didn\u2019t take any readings. This also meant that the servo could only fire every second and a half, since it would have to wait for the previous activation to finish, take a second\u2019s worth of readings, and then activate. Switching to millis() was a bit more complex and required a few variables to note timings for the sensor and servo as well as the state of the servo (the servo activation happened in several timed steps). However, the servo motor was much more trigger-happy as a result &#8211; a good thing.<\/span><\/p>\n<p><strong>2) Failed 3D print:<\/strong><\/p>\n<div id=\"attachment_13165\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13165\" loading=\"lazy\" class=\"wp-image-13165 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1415-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1415-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1415-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1415-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1415-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1415-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1415-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1415-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1415-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-13165\" class=\"wp-caption-text\">The hooks on the ends of the arms that would latch onto the monitor failed, so I had to rig up wire arms instead.<\/p><\/div>\n<div id=\"attachment_13167\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13167\" loading=\"lazy\" class=\"wp-image-13167 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1417-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1417-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1417-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1417-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1417-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1417-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1417-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1417-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1417-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-13167\" class=\"wp-caption-text\">The servo mount broke, so I braced the servo using zip ties instead.<\/p><\/div>\n<p><span style=\"font-weight: 400\">I ran into difficulties 3D printing a mount to hold the servo in place to press down on the air duster can. For one, the printer\u2019s support extruder failed during the print, causing much of the top mount to turn into plastic spaghetti and the hooks to hold the whole thing against the monitor to fail as well. Furthermore, I didn\u2019t add enough tolerance in the servo mount to fit the servo and it snapped when I wedged the motor in. Luckily, a handful of zip ties solved my problem and braced the servo well enough to hold up to pressing the air duster trigger.<\/span><\/p>\n<h3><strong>Critiques:<\/strong><\/h3>\n<p><em>\u201cThis project is meant to change a bad habit, and I like that aspect.\u201d<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">This was the goal of my idea, and I can definitely say it\u2019s worked. Pretty much as soon as I test fired the spray can after mounting it to my monitor, I was constantly aware of how close I was to the screen, because a surprise burst of air to the face is terrifying.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><em>\u201cIs the spray binary? (like it could give you a hiss warning before going to full blast)\u201d<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">I didn\u2019t consider this idea while coding the project, but it would be really easy to implement and make the sprayer a lot less scary to live with. However, I often work with noise cancelling headphones, so I\u2019m not sure if I would be able to hear the hiss warning.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><strong>Reflection:<\/strong><\/h3>\n<p><img loading=\"lazy\" class=\"alignnone size-large wp-image-13159\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/IMG_1427-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p><span style=\"font-weight: 400\">The first test-fire of the sprayer sold me completely, as I reacted with both glee and fear of the monster I created. I worked on this project with the assumption that I would get blasted by the air can frequently. However, in practice, the thought of being jumpscared by the spray can was scary enough for me to almost never lean towards the screen while the sprayer was active; in other words, the image of the sprayer became a passive deterrent without having to actually spray me much at all. Even though I\u2019ve stopped using the sprayer now, I\u2019m much more conscious of sitting close to my monitor and my sitting posture seems to have improved as a result.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">As I expected, designing a mount for the servo, Arduino, and spray bottle was difficult, but 3D printing the mount posed extra challenges I wasn\u2019t prepared for. In the end, the final sprayer was zip-tied together as I ran out of time to get a perfect 3D print. I guess I would start designing the physical parts earlier, but more time to work on this project in general would\u2019ve helped!\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Up until a few days ago, I really wanted to continue work on the sprayer, including redesigning the 3D printed mount and coding in a hissing warning. However, a few things have discouraged me from continuing. Occasionally, the sprayer will activate in error, whether it be from the Arduino crashing and restarting or the sensor throwing an error. Frankly, I\u2019m tired of testing new versions of the code using my face and don\u2019t really want a surprise blast if I\u2019m actually focusing on something. Also, the chemicals in commercial duster cans are REALLY bad for you. As in, inhaling them can slowly kill brain cells. Even if the risk of brain damage isn\u2019t as severe as an addict huffing a spray can, I\u2019m still not willing to risk my health to use air duster cans. Additionally, a compressed air pump or water jet, despite being healthier, have their own drawbacks, whether they be cost or damage to my electronics and work.<\/span><\/p>\n<h3><strong>Schematic and Block Diagrams:<\/strong><\/h3>\n<p><img loading=\"lazy\" class=\"alignnone size-large wp-image-13202\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Block-1024x327.png\" alt=\"\" width=\"620\" height=\"198\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Block-1024x327.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Block-300x96.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Block-768x245.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Block-973x311.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Block-508x162.png 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Block.png 1171w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/> <img loading=\"lazy\" class=\"alignnone size-large wp-image-13203\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Schematic-1024x734.png\" alt=\"\" width=\"620\" height=\"444\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Schematic-1024x734.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Schematic-300x215.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Schematic-768x550.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Schematic-973x697.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Schematic-508x364.png 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-content\/uploads\/2021\/04\/EZ-Sprayer-Schematic.png 1171w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<h3><strong>Code:<\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/*\r\n  60-223, Project 2\r\n  Eric Zhao (ezhao2)\r\n  time spent: 20+ hours (including physical fabrication)\r\n**\r\n  Collaboration and sources:\r\n  1) The Pololu VL53L0X Library was used to program the TOF sensor.\r\n  2) Referenced my own code from Homework 4 to time everything using millis().\r\n**\r\n  Challenge(s):\r\n  1) Going from delay to millis timing. I had to reference some of my other\r\n  code to get this to work but was able to implement it quickly.\r\n  2) The TOF sensor had a timeout function written in that would disable the\r\n   sensor\r\n  if no data in range was received after a period of time. I had to switch\r\n  libraries and read up on the replacement library's documentation to disable\r\n  this timeout feature.\r\n**\r\n  Next time: I'll start by writing comments or pseudo-code\r\n  before trying to write the actual code. I think this\r\n  will reduce my getting tangled around the code\r\n  structure by forcing me to think through the underlying\r\n  ideas more clearly.\r\n**\r\n  Description: The screen distance sprayer utilizes a time-of-flight distance\r\n  sensor, servo motor, and a can of compressed airto punish you for staring\r\n  too close to a computer screen. If you get too close to the sensor, the\r\n  servo will activate, triggering the can of compressed air and sending a\r\n  blast to your face. This is all mounted in a 3D-printed casing and hung\r\n  from the top of the chosen screen (works best for large monitors).\r\n**\r\n  Pin mapping:\r\n\r\n  Arduino pin | type | description\r\n  ------------|--------|-------------\r\n  A4      input    TOF Sensor I2C SDA\r\n  A5      input    TOF Sensor I2C SCL\r\n  3       output    Servo signal pin\r\n\r\n*\/\r\n\r\n#include &lt;Wire.h&gt;\r\n#include &lt;VL53L0X.h&gt;\r\n#include &lt;Servo.h&gt;\r\n\r\nVL53L0X sensor;\r\nServo trigServo;\r\nunsigned long lastLoopTime = 0;\r\nunsigned long lastAvgTime = 0;\r\nunsigned long servoTimer = 0;\r\n\r\nconst int READ_INTERVAL = 50; \/\/how often to measure distance\r\nint servoState = 0;\r\nint loopCount = 0;\r\nint lastDist = 0;\r\nlong avgDist = 0;\r\n\r\nvoid setup() {\r\n  Serial.begin(115200);\r\n  Wire.begin();\r\n\r\n  trigServo.write(35);\r\n  trigServo.attach(3);\r\n\r\n  sensor.setTimeout(0);\r\n  if (!sensor.init())\r\n  {\r\n    Serial.println(\"Failed to detect and initialize sensor!\");\r\n    while (1) {}\r\n  }\r\n\r\n}\r\n\r\nvoid loop() {\r\n\r\n  int currentDist = sensor.readRangeSingleMillimeters();\r\n  \/\/the VL53L0X sensor only takes a distinct reading every loop, so we\r\n  \/\/can't use a regular for loop to take an average of several data points\r\n\r\n  \/\/take an average of the last few readings. If under a set distance,\r\n  \/\/trigger the servo.\r\n  if (millis() - lastAvgTime &gt; 1500 &amp;&amp; loopCount &gt; 10) {\r\n    lastAvgTime = millis();\r\n    avgDist \/= (loopCount);\r\n    Serial.println((String)\"Number of Readings: \" + loopCount);\r\n    Serial.println((String)\"Average Distance: \" + avgDist);\r\n\r\n    if (avgDist &lt;= 500 &amp;&amp; avgDist &gt; 0) {\r\n      Serial.println(\"Servo triggered\");\r\n      servoState = 2;\r\n    }\r\n\r\n    loopCount = 0;\r\n    avgDist = 0;\r\n\r\n  } else if (currentDist &lt; 1200 &amp;&amp; millis() - lastLoopTime &gt; READ_INTERVAL) {\r\n    \/\/if the conditions to take an average haven't been met,\r\n    \/\/take a distance reading\r\n    lastLoopTime = millis();\r\n    Serial.println(currentDist);\r\n    avgDist += currentDist;\r\n    loopCount++;\r\n  }\r\n\r\n  \/\/2 = activate air can \/ start\r\n  \/\/1 = air gun activated\r\n  \/\/0 = servo retracted\r\n  if (servoState == 2) {\r\n    servoState = 1;\r\n    trigServo.write(15);\r\n    servoTimer = millis();\r\n  }\r\n\r\n  if (servoState == 1 &amp;&amp; millis() - servoTimer &gt; 500) {\r\n    servoState = 0;\r\n    trigServo.write(40);\r\n  }\r\n\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A servo-activated can of compressed air quickly teaches you to keep your distance from a monitor. Video in Action: Detail Shots: Use: Overall Process Pictures: In the above&#8230;<\/p>\n","protected":false},"author":175,"featured_media":13158,"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\/s2021\/work\/wp-json\/wp\/v2\/posts\/13146"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/users\/175"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/comments?post=13146"}],"version-history":[{"count":13,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/13146\/revisions"}],"predecessor-version":[{"id":13206,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/posts\/13146\/revisions\/13206"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media\/13158"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/media?parent=13146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/categories?post=13146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2021\/work\/wp-json\/wp\/v2\/tags?post=13146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}