This hat was actually pretty simple to make. It only had 4 electronic parts: The Gemma, the HC-SR04 sensor, one NeoPixel, and the battery. Once I connected all the parts and downloaded the software, it just worked!
I originally planned to mount the ultrasound sensor on the size adjustment strap at the back of the hat, since it was about the same dimensions as the sensor, but that would have left the hat non-adjustable, so I chose to move it to the open space above the adjuster.
I quickly mocked up a breadboard version of the hat and wrote some code to check its operation before I started sewing. I verified that the LED lit up in different colors depending on what direction the sensor was pointing, and was good to start sewing! It's hard to see in this photo, but the NeoPixel's at the center of the nest of alligator clips between the hat and the laptop. It's currently glowing green because the sensor's pointing away from everything.
I sewed the ultrasound sensor upside down to the rear of the hat, so that its pins were tucked up and into the hat instead of facing down. This will hide the wires better, and make the hat look neater when worn.
I sewed the LED near the front of the rim, but I only sewed it by the serial pass through pin, which will be unused for this project, since I’m only planning to use one LED. The remaining pins will be soldered using silicon covered wire. The brim of the hat is too thick to sew through with the stainless thread, and that would take too long and not look as nice. I’ll finish securing the LED by sewing around the wire after it’s installed.
The soldering was quick – there were only seven wires total to solder so there was little work involved. I left enough length in the sensor wire that they could be sewn to the hat for better security, but they’re just tucked into the hatband for now.
The hat we chose was coincidentally starting to come apart at one of its seams, which left a convenient hole near the brim for me to feed wires through for the NeoPixel LED. I'll sew that back up when I find some color matched thread.
The hat has a nice folded band about the bottom which is about the size of the Gemma, so it will be easy to tuck the Gemma and the battery into the band and have them hidden inside the hat. I’ll attach the LED to the front brim, as far out as I can so it’ll be visible to the wearer, and of course the ultrasound sensor will be very obvious on the rear of the hat. Since it’s intended as a plaything for a 9 year old boy, the obvious technological upgrade will be a bonus instead of a detraction from its purpose.
Here's the gemma ready to hide behind the hatband.
And this is how it looks tucked inside.
Done! The code’s already downloaded from the breadboard test, so all I need to do it connect the battery and try it out. I tried it on, and took a selfie with my phone – it looks pretty innocuous from the front. You can sort of see the green glow from the LED reflecting off my forehead, telling me that there’s currently nobody sneaking up behind me.
Here’s a different angle, with a warning that the bookcase is about to grab me!
And as I step forward, away from the bookcase, the warning changes to yellow (which is pretty white in this photo -- I may need to adjust the color).
Here’s a couple POV shots of what it looks like wearing the hat.
In this one, the wall behind me is close enough to deserve a warning.
But when I take a step forward, I'm safe. (I had to turn the lamp off to avoid overexposure from standing too close).
The kids have a party to attend this evening. I’ll bring both hats along, and see what the reactions are!
Top Comments