{"id":667,"date":"2020-04-22T22:08:43","date_gmt":"2020-04-23T02:08:43","guid":{"rendered":"https:\/\/www.mcgurrin.info\/robots\/?p=667"},"modified":"2020-04-25T13:44:39","modified_gmt":"2020-04-25T17:44:39","slug":"pocket-protectors-they-dont-just-protect-pockets-anymore","status":"publish","type":"post","link":"https:\/\/www.mcgurrin.info\/robots\/667\/","title":{"rendered":"Pocket Protectors: They Don&#8217;t Just Protect Pockets Anymore"},"content":{"rendered":"<h1>Overview<\/h1>\n<p><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/main.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignright size-medium wp-image-677\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/main-199x300.png\" alt=\"\" width=\"199\" height=\"300\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/main-199x300.png 199w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/main.png 291w\" sizes=\"(max-width: 199px) 100vw, 199px\" \/><\/a>This is just a quickly put together project to have a little fun with social distancing. The project uses an ultrasonic distance sensor, microcontroller, and an RGB LED. The set-up is hot glued to a piece of cardboard, with a battery pack glued to the folded over part that fits in a shirt pocket. If it doesn&#8217;t detect anything within 10 feet, the LED is off. If it detects something between 8 and 10 feet, it lights up green, indicating a proper social distance is being maintained. Between 8 and 8 feet, it turns yellow, and if it detects something 6 feet or less away, it flashes red to warn both parties that the proper social distance is not being maintained.<\/p>\n<p>As I mentioned, it&#8217;s just for fun, and isn&#8217;t very practical, as the sensor reacts to anything in front of it, not just another person. If you really want to get fancy, you could add a camera and face detection, so that the sensor only reacts when a person is in front of you.<\/p>\n<h1>Hardware<\/h1>\n<div id=\"attachment_668\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/full-project-scaled.jpg\"><img aria-describedby=\"caption-attachment-668\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-668\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/full-project-300x225.jpg\" alt=\"Social Distancing Sensor\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/full-project-300x225.jpg 300w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/full-project-scaled.jpg 1024w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/full-project-768x576.jpg 768w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/full-project-1536x1152.jpg 1536w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/full-project-2048x1536.jpg 2048w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/full-project-400x300.jpg 400w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-668\" class=\"wp-caption-text\">Social Distancing Sensor<\/p><\/div>\n<div id=\"attachment_670\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/ultrasonic-sensor-scaled.jpg\"><img aria-describedby=\"caption-attachment-670\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-670\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/ultrasonic-sensor-300x252.jpg\" alt=\"\" width=\"300\" height=\"252\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/ultrasonic-sensor-300x252.jpg 300w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/ultrasonic-sensor-scaled.jpg 1024w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/ultrasonic-sensor-768x645.jpg 768w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/ultrasonic-sensor-1536x1291.jpg 1536w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/ultrasonic-sensor-2048x1721.jpg 2048w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/ultrasonic-sensor-357x300.jpg 357w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-670\" class=\"wp-caption-text\">RCWL-1601 Ultrasonic Sensor<\/p><\/div>\n<div id=\"attachment_669\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/breadboard-closeup-scaled.jpg\"><img aria-describedby=\"caption-attachment-669\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-669\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/breadboard-closeup-300x194.jpg\" alt=\"breadboard closeup\" width=\"300\" height=\"194\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/breadboard-closeup-300x194.jpg 300w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/breadboard-closeup-scaled.jpg 1024w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/breadboard-closeup-768x497.jpg 768w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/breadboard-closeup-1536x995.jpg 1536w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/breadboard-closeup-2048x1326.jpg 2048w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/breadboard-closeup-463x300.jpg 463w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-669\" class=\"wp-caption-text\">A closeup of the fully wired breadboard and components<\/p><\/div>\n<ul>\n<li>The system uses an <a href=\"https:\/\/blog.adafruit.com\/2019\/01\/18\/new-product-ultrasonic-distance-sensor-3v-or-5v-hc-sr04-compatible-rcwl-1601\/\">Adafruit RCWL-1601<\/a> distance sensor. A nice thing about this sensor is that it can operate at either 3V or 5V. The sensor has four pins: Vin, Ground, Trigger, and Echo. You send a trigger pulse to make a measurement, and then the length of the return pulse on the Echo line tells you the distance.<\/li>\n<li>The microcontroller is a <a href=\"https:\/\/www.pjrc.com\/store\/teensy.html\">Teensy 2.0<\/a> that I had lying around.\u00a0 Pretty much any Arduino compatible board will work.<\/li>\n<li>The battery input is run through a 7805 voltage regulator to put our a steady 5V. I should be providing a bit higher voltage as input, but the 6V does seem to work.<\/li>\n<li>The RGB LED is one I had around, I don&#8217;t remember the model.<\/li>\n<\/ul>\n<div id=\"attachment_671\" style=\"width: 201px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/pocket-protector-scaled.jpg\"><img aria-describedby=\"caption-attachment-671\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-671\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/pocket-protector-191x300.jpg\" alt=\"pocket protector social distance sensor\" width=\"191\" height=\"300\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/pocket-protector-191x300.jpg 191w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/pocket-protector-scaled.jpg 651w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/pocket-protector-768x1209.jpg 768w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/pocket-protector-976x1536.jpg 976w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/pocket-protector-1301x2048.jpg 1301w\" sizes=\"(max-width: 191px) 100vw, 191px\" \/><\/a><p id=\"caption-attachment-671\" class=\"wp-caption-text\">The finished Social Distance Sensor<\/p><\/div>\n<p>Everything is wired up using a breadboard and then the components hot-glued to the cardboard &#8220;pocket protector.&#8221;<\/p>\n<h1>The Software<\/h1>\n<p>The software is very straight-forward. The one minor twist is that I decided that when the sensor detected something 6 feet or less away, it would flash, not just have a steady light. Because it also needed to be continually sensing, I couldn&#8217;t use delay() to do this. Normally <a href=\"https:\/\/www.arduino.cc\/en\/Tutorial\/BlinkWithoutDelay\">one uses millis() and continually loop and checking on each pass whether or not enough time had passed to turn the LED on or off.<\/a> In this case, however, I decided to measure distance four times a second (every 250 milliseconds) and also have the duration of each on or off period also be 250 milliseconds. This makes the already simple code a little simpler, but at the expense of flexibility.<\/p>\n<p>The <a href=\"https:\/\/github.com\/ViennaMike\/Social-Distance-Warning-Sensor\">software<\/a> can be downloaded from github.<\/p>\n<h1>The Test:<em> Don&#8217;t Stand So Close to Me<\/em><\/h1>\n<div style=\"width: 584px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-667-1\" width=\"584\" height=\"329\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/edited.mp4?_=1\" \/><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/edited.mp4\">https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2020\/04\/edited.mp4<\/a><\/video><\/div>\n<p>So here&#8217;s the result. My wife walked towards me holding the camera. As you can see in the video, the LED is initially off. When she gets within 10 feet, it turns green. It skipped over the narrow range when it&#8217;s yellow, but when she gets to 6 feet, it begins to flash red.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview This is just a quickly put together project to have a little fun with social distancing. The project uses an ultrasonic distance sensor, microcontroller, and an RGB LED. The set-up is hot glued to a piece of cardboard, with &hellip; <a href=\"https:\/\/www.mcgurrin.info\/robots\/667\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3,88,12,90,89],"_links":{"self":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts\/667"}],"collection":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/comments?post=667"}],"version-history":[{"count":9,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts\/667\/revisions"}],"predecessor-version":[{"id":682,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts\/667\/revisions\/682"}],"wp:attachment":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/media?parent=667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/categories?post=667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/tags?post=667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}