3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

virtual graffiti

Step 4Spray can

spray can
«
  • 4195914136_6657063ddf.jpg
  • can.jpg
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.

Testing

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.
« Previous StepDownload PDFView All StepsNext Step »
4 comments
Jan 12, 2010. 9:14 AMsc_r says:
Hey! This is cool, just got all of the bits together but struggling to download the .pde file - it just links to a .tmp file.

What gives? Could you upload it again please? or mail the code over to stuchilds [at] gmail.com

Nice one, good work Matthew :)
Jan 13, 2010. 9:00 AMsc_r says:
Thanks for this - I downloaded the .tmp file, renamed to spraycan.pde and looks like arduino code. Will have a play later.

For others: this pinout of the atmega/arduino will help:

http://arduino.cc/en/Hacking/PinMapping168

Next thing I'm struggling with is the external crystal osc:

I don't have the facilities to reset the fuse / timing on the atmega chip so thought would try to use an external 16MHz crystal.
[this one: http://uk.farnell.com/jsp/search/productdetail.jsp?CMP=i-ddd7-00001003&sku=9712526 ]

Now, as I am trying to build this circuit around an actual Arduino board I can't see a way of connecting the external osc. as pins 9/10 of the atmega chip do not have an external connection, they are linked to the onboard crystal.

Will keep updating progress.. Trying to use a pressure sensitive resistor instead of a linear pot. for the cap assembly instead in the hope that it will be a little more durable [plus I have some lying around to play with]

Lovely.
stuart

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
23
Followers
8
Author:matthewvenn
I'm an artist/engineer excited about making cool stuff!