Category Archives: Uncategorized

Contactless Volume Control

Why can’t a thing be made out of the thing that it controls?

After messing with using Arduino as a HID keyboard for a simple push to talk foot pedal I had the idea to create a USB plug in and play volume control with a novel interface. Using an ultrasonic range-finder I could control the volume by raising and lowering my hand over the ultrasonic beam. The idea of controlling sound with sound tickled me so I set about building a prototype.

I found that the range finders had reliability issues until I put a capacitor across the VCC and ground pins for decoupling and filtering. I had a 470uF capacitor to hand but this was likely overkill for the application but probably doesn’t hurt too much. I also added an RGB indicator LED that would change colour based on the volume set, the higher the volume the warmer the colour of the LED.

With the Arduino HID project library it was simple to send HID keyboard media key presses from the Arduino. I would be using MEDIA_VOLUME_UP and MEDIA_VOLUME_DOWN which each increment audio relatively. Ideally I’d use HID_CONSUMER_VOLUME instead for an absolute scale.

I programmed the control to work between 10 and 40 centimetres above the range-finder which corresponds to 0 to 100% volume. Putting your hand into the beam below 10cm mutes the volume. As there’s no way for the device to know what the volume of the computer currently is it sends 100 MEDIA_VOLUME_DOWN requests so it can be reasonably sure the starting volume should be zero. Pulling your hand horizontally out of the beam, headroom depending, gives a value greater than 80cm which it interprets as no reading, the existing value from when your hand was in the beam is held.

I added a rolling array of distance readings and averaged them for a bit of hysteresis so that changes would be smoother and errant readings ignored. It was important that the volume not suddenly jump up immediately.

For the real thing I wanted to make it fairly compact so opted to go with an Arduino Pro Micro, which has an integrated USB controller in its ATmega32U4 allowing me to use it as a plug-in-and-play USB HID (Human Interface Device) without any special drivers.

For the enclosure itself I opted to use a diecast aluminium project box and do the brushed aluminium finish that I had used before on the SIP doorbell project. I checked that everything could fit nicely, I could maybe have gone for a slightly smaller enclosure but was happy with the size.

Using a pencil I scribed out the layout, worked out an elaborate way to securely clamp the enclosure as well as back the hole with wood to hopefully reduce the chance of chipping on the back side. Using a centre punch then a pilot hole before the step bit kept the holes properly positioned, I also marked the step bit with tape to show the desired diameter. After drilling I used a countersink to deburr the holes.

With the holes drilled I was then able to offer up the rangefinder to make sure it would work in-situ and not be affected by the aluminium around it. With that confirmed working I moved on to the brushed finish.

I ran the enclosure up and down as a sled between two pieces of wood clamped into position over increasingly fine abrasive paper until eventually reaching the desired finish.

Next came final assembly, I soldered the capacitor directly to the Arduino along with header wire for the pins on the range-finder and the wires for the RGB LED which I potted into a mount for tidy installation. I threaded the micro USB cable through a rubber grommet and put a knot in it as a strain relief. I also made use of a lot of hot glue to hold the range-finder and Arduino in place.

About This Blog

This blog was started to serve as a record my university work back in 2009, in the 14 years since I’ve changed and improved a lot and what’s shown here isn’t representative of my current work. I’m leaving it as an archive in the unlikely event any of it proves useful or interesting to someone.

I hope to occasionally post updates for various projects time permitting.

Back to University

I have had a relatively productive summer working on various projects to improve my programming especially in php. The main site hasn’t really changed much apart from replacing the php GD generated GIF logo with the flash version, minor tweaks and optimisations and HTML5 compliance. The main focus of my effort has been the website for my Garry’s mod server. I have been getting feedback from its users which has been really helpful when developing my ideas and implementing new features. Hopefully I am in a good position for the year ahead.

Twiter logo circle thing ported to SVG

I have finished porting my twitter logo thing to SVG.

This was very similar to the PHP generated GIF method, I created a small function that echoes the code for each string in the SVG format. I opted to use the twitter XML feed instead of JSON as the number of requests will be higher as it does not cache any generated output.

Browser support.

Chrome/Safari work perfectly
Firefox is without animation
IE6-8 do not display without this installed: http://www.adobe.com/svg/viewer/install/ but with it work perfectly.

http://www.joredwood.co.uk/svg.php

Twiter logo circle thing ported to Flash

I have finally ported my twitter feed rotating logo thing into flash. So far it has been made in Processing, php GD generated GIF and flash and attempted in inconsistent HTML-CSS-JS. I have not yet decided what format to try to port to next, HTML5 canvas looks like a dead end for now based on what I have managed to find out and processing.js has some way to go till it supports all the necessary functions.

I have chosen to port this to various formats as practice of different languages without having to redo the core logic of the code that is to import the string, divide the string into each letter, measure the width of each for correct kerning, calculate the position and rotation around the circle, draw the character. This allows me to focus on the differences between the languages themselves.

I may release the source for some of these at some point in the future.