Friendship & French Fries

A podcast & blog about life and the creative pursuit of happiness

[Midterm] Personal Safety Sensor

[Midterm] Personal Safety Sensor

Midterm time!

The assignment: a “stupid pet trick” that combined any of the concepts we’ve learnt so far.

My partner: Xiwei (Eva) Huang

The idea: A personal safety sensor.

Coming from a big city, safety has always played a role whenever I’m out and about. I was always taught to pay attention to my surroundings, and be mindful of where all of my stuff (purse, jewelry, etc) was at all times.

Because of this, I had an idea a couple of weeks ago to create a personal safety sensor that would be placed on someone’s back and if someone was coming at them from behind lights and sounds would come on to 1) alert the person and 2) deter the attacker.

I brought it to Eva and she was very much up for the idea. We both had ton of proximity sensors, so it seemed like a great fit for us to try.
We got to work on making the sensor work with a light first, since I had experimented with it already and we had a base code to go off on.


From there, we worked on adding a speaker to it to see if would still work. Here is were the troubles started. I think we spent a total of two days trouble-shooting this code. Sometimes the sensor wouldn’t work, sometimes the light, the speaker NEVER worked. If the speaker was plugged in the sensor value would drop…. I mean, it was just chaos in our corner.


After, we decided to switch from an ultrasonic sensor to an IR sensor to see if we could make it work better. We messed around with it, changed the code and just troubleshooted for a while. The idea was to get the speaker to make a buzzer sound and the LED to light up if the sensor got that you were 50cms or closer to it .We mapped the ranges, messed with it but I just don’t know what the problem was.

At some point, all three components were set up as analogue (sensor, LED and speaker), with nothing working. I decided to take a step back and and start a new sketch to just make the speaker work with a potentiometer. From there I added the LED to it, and after I got them both to work the way I wanted to, added the sensor. I don’t know how, but it worked!!! See the code below:

IMG_3041 Since that was working, we decided to try again and make the LED analogue, so that it would dim based on the proximity of a person. It worked again! From there it was a matter of putting it together in the prototype. I had received an Adafruit order recently and the box seemed to be a perfect fit, so we cut out the parts for the components to stick out, added an on/off button (so that the user can turn off the box whenever he/she wants to or if they’re in close quarters like a subway) and voila! The first pass at the personal safety sensor we had imagined! IMG_3044 IMG_3046 Although it didn’t quite turn out the way wanted it, it was great to be able to work on something a little more robust!




thumb_1O5A8763_1024 Final Code:

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top