Introduction: Personal Space Defender

About: I make projects, they have names. Some are obscure and some straightforward. Form or Function; I go either way. Battery powered or edible, I love making things.
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.  


DSCN1778 from Aleksei Sebastiani on Vimeo.

Step 1: Parts

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


#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 sensorint inchesAway; // inches away from the maxsonar sensorvoidsetup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'Serial.begin(9600);
}

voidloop() { 
inchesAway = analogRead(sonarPin) /2; // reads the maxsonar sensor and divides the value by 2// approximate distance in inchesSerial.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 soundlong 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 sensorif ((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: elseif (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.  

Step 5: Assembly of Bow Tie

Your flora pixels should snap in place quite nicely.  Next, solder everything together(out to in, +volts together, grounds together).  Lastly, take some super glue and affix the holders.  

Step 6: Flora Assembly

Pretty simple here.  Secure the magnetic backing to the flora and solder on the 5mm snaps.    For my code, you are going to solder snaps to pins 6 & 9, ground and 3.3v.  I wanted to limit the amount of wires going to the bow-tie, so I shared the ground and 3.3v wires between the distance sensor and the flora pixels.  

Step 7: Neck Strap

Measure your neck.  Mine is about 16".  A little extra is ok.  Cut the fuzzy side of the Velcro to that length.  Feed the Velcro though the loops.  Next, solder the remaining connections.  Lastly, cut some small pieces of the hook side Velcro to secure the wires that feed the bow-tie.  

Step 8: Defend Yourself.

Wear it and Love it.  

Arduino Contest

Participated in the
Arduino Contest

I Could Make That Contest

Participated in the
I Could Make That Contest

Weekend Projects Contest

Participated in the
Weekend Projects Contest