Enter the maze

Firefly

A tree with fairy lights on it

Imagine. Imagine sitting with a laptop on the bank of a river as it flows through the city centre. Both sides of the river are lined with trees decorated with lights. Now imagine all the lights make up a giant computer screen that can display pictures or messages in 3D. And you control them.

This was an idea someone floated in one of those random what-if discussions inventive people tend to have when sitting around chatting over a drink. With most groups such up-in-the-clouds ideas wouldn't go much further, but this group of people were computer scientists from Lancaster University, and they were intrigued. So they decided to make it happen.

The result they came up with is called Firefly. One of the team, Alan Dix, has been telling us about how it works.

Christmas tree lights can of course flash in different patterns, but those patterns are pre-set before the lights leave the factory. The different patterns are a result of the way the lights are physically wired together. Using physical wiring has two problems. First it’s not very flexible. To change the lighting effect you may have to rebuild it from scratch. Secondly it uses a lot of wire and wire is expensive.

What the Lancaster team were thinking of was something different. What if you made every individual light a networked computer? It would be like connecting them into a mini-internet. If each light is a computer then it can be programmed to do clever things, rather than putting the cleverness in the physical structure.

A closeup of a microchip

Each firefly light is made of a single LED, its own personal microprocessor, a capacitor and a diode. Nothing more. Thousands of these can then be strung together in long lines using a pair of wires, with a computer that acts as a network controller at the end. This is how the computers in a school or office are often networked together. By sending instructions over the network from the network controller to all the microprocessors, the lights can then be switched individually.

Wait a minute though. Aren't computers a bit expensive to be putting them into thousands or even millions of individual lights? That's the surprising thing. No! Computer chips are very, very cheap. In fact, the most expensive part of each Firefly light is the LED not the microprocessor. Remember too that Firefly saves money by doing away with the expensive wiring other lights depend on. Less wiring makes Firefly greener than other lights too.

OK, so you have strung together lots of computer-controlled lights. How does that get you any closer to your riverside vision of controlling a 3D display in fairy lights? Well, now for the really clever bit. You pretend each light is a tiny part of a massive computer screen.

A normal computer screen is made up of thousands of individual lights, or pixels. Each can be switched between different colours. The pixels can be combined into images because they are positioned in a regular grid, and the computer knows the location of each one. That makes it easy for a computer to know which pixel to switch on to show the desired image.

Trees aren’t exactly as smooth and regular as a flat screen, though. If we string our Firefly lights around a tree (or any solid object for that matter), their actual positions are hard to control. To turn them into a display we need the network controller to know exactly where each one ends up.

So, how do we do that? Easy. Just position three cameras round them, and instruct each light to flash its own unique pattern. A computer vision program can then use the three camera images and some simple geometry to spot each pattern and figure out exactly where it’s coming from.

Numbered bingo balls tumbling around a drum

Actually there is still a slightly tricky problem to overcome. To make the microprocessors as cheap as possible they all have to be identical. That means there is no way of telling them apart once they are strung together. They would all hold the same program and all flash the same pattern! To get round this each microprocessor needs to be allocated an identity number to tell it apart from the rest. These numbers can also identify which ones are being told to switch on at any time. Assigning a number from the central, controlling computer isn't easy. Instead, it turns out to be easier to get each microprocessor to just pick a number itself. In a perfect world, as all the chips are identical, they would all pick the same number. Luckily the world, and particularly chip manufacture, isn't perfect. The speed that different chips do things is very, very slightly different. If each picks a number based on that timing they will mainly end up picking different ones.

The network controller then just needs to know if any two chips did pick the same number by chance, and get them to pick a new one. The Lancaster team came up with a clever way to do that too. They realised that there is a noticeably large drop in power when more than one light switches on. The controller can watch for that happening.

How does the controller do that? First it sends a command to all the lights saying that any chip that picked number 1 should flash its light. Next tell those that picked number 2 to do so, and so on. Each time the controller watches the power drop to see if more than one light came on. If that happens, the offending chips receive a message telling them all to choose a new unallocated number. The result is that is eventually every light has a unique identity and the programmers can go back to creating their 3D map. Because each light has a unique number, it will flash a unique pattern at the three cameras, waiting to create a three-dimensional map of the sea of pixels.

With this 'calibration' process done, the tough part is out of the way. Now you just use a 3D drawing program to draw pictures in virtual 3D space on your computer. The controller can switch on the lights in the equivalent places out in the real world. You could program this in advance or control it interactively – draw in the 3D space and see your pictures immediately appear out there in the trees. The pictures you create don't need to be still of course. You could create a 3D animation, with words or pictures snaking around the trees along that riverbank.

Once you've started thinking of lights like this you can imagine some more. Imagine being in a stadium where everyone is holding a light stick. The light sticks around you are all pulsing in some mysterious pattern. Look across to the other side of the stadium and you see the ones there are showing a gigantic image of the action on the pitch. You are too close to see, but that's what yours are doing too!

Imagine instead that that you are in a concert hall, the audience behind and an orchestra in front. As the conductor conducts the orchestra you conduct the light show. Every gesture is picked up by cameras and turned into changes in images that fill the auditorium.

Imagine now controlling lights on roofs across a city. As planes circle above, waiting to land, the passengers looking out the windows see more than just the lights, they see city-sized images as the city itself welcomes them.

Think bigger still. Imagine looking out of the space station at the lights of the continent passing below...

Perhaps the sky isn't the limit for good ideas after all.