Introduction: Virtual Graffiti

About: I'm an artist/engineer excited about making cool stuff!
I've seen a few virtual graffiti systems on the web but couldn't find any information published on how to make one (though see final links page). I thought it would be great for my graffiti workshops, so I made one myself and have published everything you need to make your own here!


* all open source and hardware,
* cost < £100 excluding projector and computer,
* detects can's nozzle pressure and distance from the screen,
* models paint dripping if you move too slowly!


* this instructable is quite high level, but please let me know if I've missed something important,
* the computing setup is for Linux. If you get it working on other systems, please post your instructions!

Skills you'll need

* wood working to make the wooden rear projection screen,
* electronic circuits and programming Atmel AVR micro controllers (or arduino),
* be able to install some libraries on your computer to allow processing to talk to the wiimote.

Step 1: How It Works

* The spray can has an infra red LED that shines through the projector screen and is seen by the wiimote's camera.
* The wiimote sends the X and Y co-ordinates of the can to the computer via a bluetooth radio link.
* The computer is running a simple painting program that uses a projector to "paint" the lines as you draw with the can. It also takes care of mapping the wiimote camera to the screen using a 4 point calibration system.
* The spray can also detect its distance from the screen and the nozzle pressure: the further you are away the bigger the dot drawn, the harder you press the nozzle, the more opaque the paint dot becomes.

Step 2: The Components

Here are all the bits you need to get together:

* computer - needs to be about 1.4Ghz, bluetooth and a usb port,
* processing environment,
* virtualGraffiti software, download from the "computer setup" step,
* nintendo wiimote - buy second hand from ebay,
* projector - it will need to be bright if you're planning to use during the day or inside with lights on,
* rear projection screen - make yourself,
* virtual spray can - make yourself,
* virtual spray can receiver - make yourself.


* arduino for can receiver (built in usb->serial) £21
* radio rx/tx pair £9
* components for building spray can £18 plus optional enclosure £12
* optional enclosure for receiver £8
* nintendo wiimote - buy second hand from ebay £20

Step 3: Rear Projection Screen

The screen needs to be just the right amount of see through-ness! If it is not transparent enough, the image won't be seen and the infra red LED won't be visible to the wiimote's camera. If it's too transparent then the projector will be blinding and the image washed out. (Though see the last page for ways of mitigating this).

I used lycra, which is stretchy so I can stretch it to make it more transparent. At the moment I hold it on with thumb tacks, but I'm graduating to velcro when I get access to a sewing machine.

I made a wooden frame with the help of a workshop and a carpenter (thanks Lou!) I needed it to collapse so I could transport it on my bike. If you're making one for a fixed venue then it will be easier to make. Just make it at a 4:3 aspect ratio, and stiff enough to stay upright.

I've found people tend to push on the screen material a fair bit so it needs to be a bit rugged.

Step 4: Spray Can

This is the most complicated part of the project and took the longest time to get right. The good news is that you don't need all this stuff to make a fun system work. The simplest thing is just to get a circuit with a switch, and infra red LED and a resistor. When you push the switch the LED lights up and is seen and tracked by the wiimote's camera.

This version is more advanced, because it also measures the distance from the screen and the nozzle pressure. Both these things are important when you're actually spray painting. I wanted to make a training system, so it was important to make the system as "real" as possible (within my cost limits).

The circuit is pretty simple. Take a look at the attached circuit diagram to see for yourself. You need basic soldering skills and to be able to put a circuit onto veroboard. Also, you should feel happy with programming microcontrollers.

Building a circuit from scratch vs using an arduino board

option 1: if you want to use an arduino board in spray can. Use arduino as is and halve the baud rate of the radio tx in the spraycan code.

option 2: you want to save cash but you don't have a fuse programmer. Build the board and use a 16MHz external crystal. Halve the baud rate as in option 1.

option 3: you want to save even more cash and you have a fuse programmer. Build the board, but omit the external crystal. Use the fuse programmer to set the atmel to use its internal clock. I believe this DIY parallel programmer will allow you to program fuses. I use the olimex programmer.

Overview of the circuit

The microcontroller measures the output from the sharp 2d120x distance sensor (great info on this sensor here) and the linear potentiometer. It also measures the output of the LED PWM potentiometer. This is used to adjust the LED's light output. The IR LED I'm using is 100mA and peak wavelength is 950nm (ideal for wiimote).

The microcontroller uses PWM to flash the LED very fast. We use an IRF720 power mosfet so that the micro doesn't burn out its output. Also I wanted to add capacity for a brighter LED in the future.

There is a status LED that flashes everytime a data packet is broadcast on the radio. If everything is working well, this light should be flashing at around 15Hz.

Finally, the radio transmitter module is attached to pin 3 (digital pin 1 for arduino) of the microcontroller so that we can send the information we're measuring to the computer.

You also NEED an aerial attached to the receiver board. I used a 12cm long peice of wire. This is half what is recommended on this excellent info page.

Programming the microcontroller

After you've built the circuit, you'll need to upload the program (attached). I use the arduino programming environment/libaries. You can compile this with the arduino IDE, and then program it however you usually do.

My circuit is made simpler by using the internal 8MHz clock of the micro. If you use this you'll need to set the fuse settings to use the internal 8MHz calibrated RC:  1111 0010 = 0xf2

This means you'll need to have a programmer that can write fuses.

./avrdude -C ./avrdude.conf -V -p ATmega168 -P /dev/ttyACM0 -c stk500v2 -U lfuse:w:0xf2:m

If you don't have this kind of programmer (say you just have the arduino board), just use a 16MHz crystal between pins 9 and 10 and it should all work (untested - you may need a capacitor). You'll also need to modify the program code so that the transmitter baud is halved.


After you've got it all together and the program loaded, you need to adjust the IR LED brightness. I just wanted to maximise light output without toasting the LED so I blew a few up and ended up with about a 120ma draw average.

If you have a multimeter you can adjust this quite easily, otherwise just adjust the potentiometer to be quite high but not all the way! You can also check the analogue inputs on pins 26, 27 and 28 of the PWM adjust potentiometer, the distance sensor and the nozzle potentiometer.

If you have a scope you can check the pulse train coming out of pin 3 into the radio TX module. Check the pwm output of the LED on pin 11.

You can use a mobile phone camera (or most CCD cameras) to see the IR LED turn on when you press the nozzle button.

Step 5: Spray Can Receiver

If you're going the simple spray can route then you don't need this bit.

Otherwise, I just use an arduino board, with the radio receiver plugged into the pin 2. This makes it easy to get the data into a computer via the USB -> serial chip on the arduino board. If I was going to make a custom circuit I'd probably use an FTDI USB -> serial UART evaluation board.

You also NEED an aerial attached to the receiver board. I used a 12cm long peice of wire. This is half what is recommended on this excellent info page.

Load the graffitiCanReader2.pde sketch into the arduino. With the can powered up, you should see the status LEDs on the can and the receiver board flashing quickly. Everytime the can LED flashes, a data packet is sent. Everytime the receiver board LED flashes, a valid data packet is received. If you're not seeing this then there is something up with the radio link. Something to try is connecting the TX of the can to the RX of the receiver with a piece of wire. If this doesn't work then you probably have a mismatch in the baud rate of virtualwire (see the code).

Assuming you've got lots of flashing going on on the receiver board, you should be able to monitor this on your usb serial port. If you monitor the serial port (usually /dev/ttyUSB0) at 57600 you should see data spewing out like

Got: FF 02
Got: FF 03

The first number is pressure, and the second is distance.

Now you can run processing and use this information to make pretty pictures!

Load the attached processing sketch (canRadioReader.pde) . Start the program and check the output of the program. You should be getting a frequency (that tells you how many updates per second the receiver is getting - you definately want this to be at least 10Hz). Also you'll get a distance and nozzle measurement. Test the can by moving the nozzle potentiometer and by moving a peice of card in front of the distance sensor.

If it's all working, then move on to the next step - getting the computer ready to talk to the wiimote!

Step 6: Computer Setup: Processing and the Wiimote

Our main here is getting processing talking to the wiimote.

These instructions are Linux specific, but it should all work on a mac and windows with some research on how to get the wiimote's data into processing.

After installing processing, I found some instructions on the forum, but I still had some problems. Here is what I had to do:
  1. install processing
  2. install bluez libraries: sudo apt-get install bluez-utils libbluetooth-dev
  3. create ./processing/libraries/Loc and ./processing/libraries/wrj4P5
  4. download bluecove-2.1.0.jar and bluecove-gpl-2.1.0.jar and put into ./processing/libraries/wrj4P5/library/
  5. download wiiremoteJ v1.6, and put the .jar into ./processing/libraries/wrj4P5/library/
  6. download wrj4P5.jar (I used alpha-11) and put into ./processing/libraries/wrj4P5/library/
  7. download and unzip into ./processing/libraries/wrj4P5/lll/
  8. download Loc.jar (I used beta-5) and put into ./processing/libraries/Loc/library/
  9. download and unzip into ./processing/libraries/Loc/lll/

Then I used code inspired from Classiclll to get the buttons and sensor bar working. The attached code/sketch just draws a circle where the 1st infra red source is found by the wiimote.

To check your bluetooth, press buttons one and two on the wiimote, then try

$ hcitool scan

at the terminal. You should see the nintendo wiimote detected. If you don't you'll need to look at your bluetooth setup further.

If it's all good, load the wiimote_sensor.pde (attached) program and start it. In the lower status part of the screen you should see:

BlueCove version 2.1.0 on bluez
trying to find a wii

Press buttons 1 and 2 on the wiimote. After it's detected, wave your infra red source (the spray can) around in front of it. You should see a red circle following your movement!

Make sure this works before moving on. If you can't get it to work, search the processing forum.

Step 7: Setting It All Up

Download the virtualGraffiti software below. Extract it into your sketchbook directory and then follow these steps!

* power up spray can, check status LED light is flashing.
* turn on computer, plug in spray can receiver,
* setup screen and projector,
* check that spray can receiver status LED is flashing,
* start processing and load the virtualGraffiti program,
* check that you're getting both RX and TX serial indicator LEDs are flashing on the arduino board,
* press both buttons on wiimote,
* do 4 point calibration when prompted (put spray can over each target in turn, then press the nozzle till the writing goes red).
* have fun!

Step 8: Resources, Links, Thanks, Ideas


Here are the links that were invaluable in making this project work:

RF info:



Using wii with processing:



4 point calibration:


Without a lot of people publishing their work, this project would have been a lot harder and more expensive.

Massive thanks to all open source crew, people who hacked the wiimote, Classiclll for making wiimote easy to use with processing, Jochen Zaunert for code to do calibration, processing crew, arduino crew, Lou for carpentry help, and all those who explore, make and then publish their findings online!

Other people's systems

* I only just found, with open source software and a howto
* this system allows use of stencils: cool!, no code or howto
* yrwall's virtual graffiti system, no code or howto.

Ideas for exploration

* use 2 wiimotes to do 3D volume tracking and do away with distance sensor in the can: This would be good because the distance sensor is currently the weakest part of the system. It would also mean we could use a proper rear projection screen for more vivid images.

* use a wiimote in the can to detect angle of spray can. This would add realism to the spray paint model.