What could be better than having a little instrument with you all the time, hidden in your hat?
Insiders Tip: Don't take this to the airport. The inspiration for this project came while on the long road trip to Austin last weekend, and I finally had some time to make it. The prototype is a bit rough, but I think it gets the point across well enough. Walkthrough of the project and schematic after the break. I started off with a 555 timer VCO circuit that I found at ecelab.com. Next, I hooked up a Sharp GP2D120 infrared distance sensor that I had laying around from another project, and added a cheap level shifter to allow the sensor to control the oscillation frequency of the 555 timer. Once that was basically working, I played around with the potentiometers until I had a range of sounds that seemed reasonable.
The schematic ended up looking like this:
Once I had the prototype working on a breadboard, the next step was to transfer the design to a perfboard that would be suitable for mounting in the hat. The top picture here might look somewhat neat, but believe me when I say that it is a complete hack job underneath. Hey, though, it seems to work ok.
Finally, I put the module together with a battery, speaker and (momentary) on switch, and Velcroed each piece to the (except the switch) inside of my hat. I cut a small slit in the side of that, ran the wires for the switch through that, and then stuck the switch under one of the side curls on the outside. This way, you can start playing music by picking up the hat as you normally would, but also catching the switch in the same motion.