Personal Space Defender




A simple and elegant way to help keep your personal space bubble from being invaded by close talkers and overly huggie people.   This is a stolen or borrowed idea from Phillip Torrone of Adafruit, who mused about something like this on an episode of Adafruit’s “Ask an Engineer.”  I decided to incorporate this idea into a bow-tie for all those black tie events that I’m forced to attend(no not really, it just seemed the easiest and most discrete way to incorporate the sensor).  The jist of  how it worked is as follows;  If someone gets within 19″ of me, red lights flash for a few seconds.  If they stay there, the lights keep flashing.  The distance and flashing rates can easily be changed to suite your needs if your personal bubble is larger or smaller than mine.

Personal Space Defender




Step 1: Parts

Major Components in Project

Adafruit Flora  http://www.adafruit.com/products/659
Maxbotix distance sensor  http://www.adafruit.com/products/172
Adafruit Neo Pixel   http://www.adafruit.com/products/1260
3D printed Bow-tie  https://tinkercad.com/things/lMtQ1vbMAHI-space-invader/
Bow-tie loops   https://tinkercad.com/things/77nV1o6NTgt-bowtieholder
Acetone
Velco  or fabric collar
Wire & heat shrink
5mm snaps  http://www.adafruit.com/products/1126
Magnetic backing  http://www.adafruit.com/products/1170

Step 2: Code

Code

#include <Adafruit_NeoPixel.h>

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, 6, NEO_GRB + NEO_KHZ400);
int sonarPin = 9; //pin connected to analog out on maxsonar sensor

int inchesAway; // inches away from the maxsonar sensor

void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
Serial.begin(9600);
}

void loop() { 
inchesAway = analogRead(sonarPin) /2; // reads the maxsonar sensor and divides the value by 2
// approximate distance in inches
Serial.print(inchesAway); // prints the sensor information from the maxsonar to the serial monitor 
Serial.println(" inches from sensor");
if (inchesAway < 19) { // if something is 24 inches away then make a 1khz sound
long startTime = millis(); // record the beginning of the proximity event.
    while (inchesAway < 19)
    {
         if ((millis() - startTime) >= 3000)  // If we have been in this loop for 5 seconds
         {
              break;  // exit the loop
         }
         inchesAway = analogRead(sonarPin) /2; // keep reading the sensor

     if ((millis() - startTime) >= 3000)  // we passed the 5 second test
     {

   for(int j = 0; j < 30; j++){  

         for(int i = 0; i < 4; i++)
{
  strip.setPixelColor(i, strip.Color(250, 0, 0)); 
}
strip.show();
delay(100);
for(int i = 0; i < 4; i++)
{
  strip.setPixelColor(i, strip.Color(0, 0, 0)); 
}
strip.show();
delay(100);// Flash the leds
     }
}

// turn LED on: 

else if (inchesAway > 18){

strip.setPixelColor(1, strip.Color(0, 0, 0));
}

    }//end while
    }//end if
  }//end void loop

Step 3: Getting Help

Aside from great delivery and awesome products, one of the biggest reasons that I love Adafruit so much and buy most of my Arduino related products from them is that the support for their products is unparalleled.  I reached a snag on this project when the coding when beyond my abilities.  I choose to go to the forums for help.  Arduino, Adafruit, and Instructables all have great forums and amazing super-users who are willing to help.  However, when going to forums don’t think that anyone else will do all the work for you.  Or ask vague questions that are unanswerable.   If you want help from forums, make it as easy as possible for someone else to help you.
Having said that, I’d like to send many thanks to Adafruit_Support_Bill for helping me get my code to where it needs to be.  I couldn’t figure out how to add a time element to the sensor in order to avoid false positives(like when drinking wine or making some gesture with my hands).  He graciously provided the code that I needed.   Thanks again Bill!
http://forums.adafruit.com/viewtopic.php?f=8&t=42504 <—–here’s the forum thread.

Step 4: The Print

Firstly, I printed a few grey rough drafts of my prototype.  I had thought that printing the loops that the velco strap would go through would be a good idea.  It wasn’t.  It added a bunch of support to the holes that the pixel would lay in.  It took a few rough drafts and measuring before I had a design that was good enough.

I printed the final item upside down so that the holes for the flora pixels would end up being a nice snap fit.  This means that the top side of the print would need a lot of finishing and cleaning.  It was printed with support that had to be removed.  After that, much sanding took place and then a final finishing with an acetone wiping.  See the pictures below for the progression of the 3D printed part.

 

For more detail: Personal Space Defender




Clip to Evernote

Leave a Comment

(Spamcheck Enabled)

Read previous post:
TMS0803/5 Emulating Calculator Build

MSP430G2452 acting as a TMS0803 calculator chip. Emulates TI DataMath 2500II and Sinclair Scientific Calculators. Description I got introduced to a...

Close
Scroll to top