Sunday, 22 April 2012

Electronics to keep the wife happy

This weekend I decided to do something a bit more obviously useful than my usual projects. My house includes a cupboard under the stairs that is lit by a battery powered light. However, the light is a bit useless as it is always running out of battery really quickly.


The first step is to open up the light and take a look inside. This turned out to be quite straightforward as I just needed to remove four screws and pull the top off.

The internals are very simple with color coded wires. The only surprise is that there was a round female connector fitted to a round hole on the rim of the light. This looks like it would allow the light to be mains powered but that is no good to me as there are no sockets in the cupboard I'm using the light in.

With the cover off I took the chance to measure the current used when the light is switched on. The result: 500mA! No wonder the batteries lasted for such a short time! However, I'm not entirely surprised by this result as the light was using an incandescent bulb.

As an aside - I always find measuring current really awkward as you have to insert the multimeter in series in the circuit which is tricky when the probes are just pointy metal tips rather than clips which can hold a wire.

The next step is to make this light better. I decided the easiest way to do this would be to replace the incandescent bulb with an LED. I took a look on maplin and picked out a bright white LED which runs at 3.6V and only draws 100mA to produce 18000mcd of light. According to this site 18000mcd is 2.1 lumens which compares to 850 lumens for a 60w incandescent light bulb.

The 3.6V requirement means that I only need three of my 1.2V rechargeable batteries and won't need to add a resistor. The first step was to insert a wire instead of the fourth battery.

The next step was to remove the incandescent bulb along with its screw socket (which I have saved in case I ever need them in another project) and solder an LED in its place. The only tricky part of this was that the wires in the light were stranded instead of solid core which made the soldering more fiddly.

That's all there was to it. I put the case back together, turned on the light and took a picture.

The light is brighter than this picture suggests (my phone overcompensated with the exposure) but it is a bit less bright than I had been hoping. In future I might add an extra LED or two which would double or triple the light output with a corresponding reduction in battery life (more LEDs = more current but the same voltage).

Once everything was assembled I got out my multimeter and measured the current and was pleasantly surprised to find the current was only 70mA rather than the expected 100mA. Since I am using 1700mA batteries this means I expect a battery life of about 24 hours compared to the 3 hours which I would have got with the incandescent bulb.




Wednesday, 18 April 2012

Wiimote Head Tracking - Follow Up

After my previous post I came across some interesting related content.

More Head Tracking

I found a tutorial which used a different Wii library (Wii Yourself) and describes how to create a clone of the Johnny Lee VR demo using Ogre3D.

Light Brush

I also decided to take a look at r/arduino and quickly spotted an interesting related project which uses the Wiimote as part of an Arduino powered Light Brush. The reddit thread credits this blog ( with the idea and links to this blog ( about the implementation referenced in the reddit post.

A bit of further googling turned up which was an interesting post about trying to implement a light brush. This post also links to some other similar projects such as the Lightscythe.

Monday, 16 April 2012

Wiimote Head Tracking


In December 2006 the Nintendo Wii was released. This included the Wiimote controller which provided an interesting new motion tracking system. The Wiimote connects to the Wii over Bluetooth and includes two kinds of sensors. A 3-axis accelerometer and an IR camera. For the purposes of this post the camera is the more interesting part.

The infrared camera has a resolution of 1024x768 with built-in hardware blob tracking of up to 4 points at 100Hz. This is used in combination with the Wii sensor bar which is actually just an array of 6 IR LEDs, 3 at each end, to provide accurate motion tracking of the Wiimote when it is pointed at the sensor bar.

In December 2007 a develope called Johnny Chung Lee posted a video showing how the Wiimote could actually be used in reverse to accurately track a users head. This involved mounting IR LEDs on some glasses to take the place of the sensor bar and placing the Wiimote in front of the screen pointing at the user.

This demo was built on top of the Wiimotelib C# library for using the Wiimote on windows. A forum which discusses the head tracking demo is available here.

In a recent episode of Gadget Geeks on Sky One they used this technology to build a virtual window for a hotel room. This inspired me to investigate the technology myself.

My Hardware and Results

To build my own IR glasses I bought the following components:
I connected the battery, switch, LEDs and resistor together in a simple series circuit and built the circuit around an old pair of cheap sunglasses which I found at home. I was quite pleased with how the results looked.

The complete glasses:

Close up on the side with the switch and the battery.

Full view of the side with the battery.

I then setup a Wiimote on top of my TV with some masking tape holding it in place. I used some more masking tape to hold an iPhone wide angle legs in front of the camera to give it a wider field of view - the camera normally only has a ~45 degree field of view.
A view of the TV including the attached Wiimote:
A close up of the Wiimote:
The results can be seen in this video.


I was quite pleased with how good this looked. However, the are a few key limitations.
  • The lack of stereoscopic depth cues means that in person the 3D effect is much less effective than the video would suggest. If I combined this head tracking with a 3D TV I expect the combined effect would be really impressive.
  • The field of view of the Wiimote camera is a really limiting factor as it is easy to move out of its view at which point obviously the head tracking stops working.
  • The previous limitation is made much worse by the fact that the camera only works over fairly short distances. I found that once I moved much more than a meter away from the camera it started to struggle to keep track of me. This forces you to stay much closer where the narrow field of view is more annoying.

Other Consoles

The Wii has sold the highest number of units out of the current generation of games consoles (vs the Xbox 360 and PS3). However, as of Autumn 2010, both of the rival consoles have released their own motion tracking systems. Interestingly, both of these systems work in a similar way to the camera based head tracking covered in this post. In fact, the original creator of the head tracking demo, Johnny Chung Lee, ended up working on the Xbox Kinect development team.

Xbox Kinect

The Xbox Kinect system uses an infrared projector to project a pattern of infrared light. This is then captured by a 640x480 pixel 30fps infrared camera. This input is augmented with a 640x480 pixel 30fps rgb camera. The advantage of this approach is that the IR light source and detector can be contained in the same package and the player doesn't need to wear/hold anything to be tracked.

It is interesting to note that both the resolution and frame rate of the IR camera is lower than the one used in the Wiimote.

Playstation Move

The Playstation Move uses an approach which is much closer to the one described in this post. The Playstation Eye camera provides a 640x480 60fps rgb picture which works even in very low light. This enables the use of the Playstation Move controllers which have a coloured sphere on the end. The system automatically picks the best color to stand out against the current background and then uses simple image processing to track the coloured sphere within the camera image. The known size of the sphere allows for the accurate measurement of depth.

Once again the actual resolution of the camera being used is lower than the one used in the Wiimote.


Johnny Chung Lee has a blog which has some interesting posts about motion tracking and other tech topics. The post which stood out to me was this one. In particular, the following two videos are pretty exciting. Both of these are systems that work entirely by analysing RGB video without any extra sensor data.

Monday, 9 April 2012

New Blog - Coding

I haven't been doing much work on Arduino projects recently as I have been spending all of my time on coding projects. I have enjoyed posting to this blog so I have started a new blog to talk about these coding projects.