I put together this little bit of electronics for an upcoming art show. My goal was to create a device that would demonstrate the Northern European need for personal space. It sounds an alarm when someone gets too close.
I will put a video of the device in action here.
The prototype was built on a breadboard and powered by an Arduino Uno. Once I had everything wired up and the programming more-or-less finished, I built the enclosure from a plastic box that was lying around. I cut holes for the various components, making sure they would fit together on the inside.
Those components include ultrasonic distance sensor, which I got from Radio Shack. It works like a charm.
The heart of the device is an ATMega 328, which is a great chip. Since I ran out of capacitors, I had to figure out how to get the chip to run with the inaccurate internal timer. To do this, I used two Arduinos: the first acted as a serial programmer to install an internal-timer bootloader on the ATMega 328 in the second. With the correct bootloader, everything proceeds as expected (recalling, of course, to select the internal timer bootloader when uploading from the Arduino IDE).
When the device measures a distance less than X to a person, it does three things. First, it displays a message on an LCD screen, depending on X. Next, it flashes either two or four red LEDSs. Lastly, it makes one of two pitches of sound from a piezoelectric cell. Here are those components, wired up.
The device is powered by a 9V battery, so I use a regulator to reduce to 5V. There are also a couple capacitors and a power switch — all good practice but maybe unnecessary.