Update: a much more thorough explanation of this project is available from Make Magazine. It might be easier to follow their instructions, and I think their code is more up to date.
The basic goal here was to make a 3D hand-position sensing system that most people can build, while still preserving some semblance of functionality. To get an idea of possible applications, check out the demo video. If you think you can build one that is simpler and equally accurate, or slightly more complex and more accurate, share in the comments!
DIY 3D Interface: Tic Tac Toe from Kyle McDonald on Vimeo.
Step 1: Materials
Tools
- Arduino
- Processing
- Wire cutters
- Soldering iron
- Box cutter
Materials
- (3) 270k resistors
- (3) 10k resistors
- Solder
- Wire
- Aluminum foil
- Cardboard
- Tape (e.g.: scotch)
- Shielded wire (e.g.: coaxial cable, ~3')
- (3) alligator clips
- 3-pin header
- Zip-tie
- Shrink wrap tubing or hot glue
Step 2: Make the Plates
Don't tape down the entire perimeter, we'll need it later for attaching the alligator clips.
Step 3: Make the Connectors
- Cut three equal lengths of shielded cable. I chose about 12". The shorter the better. Coaxial cable works, but the lighter/more flexible the better.
- Strip the last half inch or so to reveal the shielding, and the last quarter inch to reveal the wire.
- Twist the alligator clips to the wires onto the wires and solder them together.
- Add some heat shrink tubing or hot glue to keep things together.
Step 4: Make the Circuit
- Set the pin to output mode.
- Write a digital "low" to the pin. This means both sides of the capacitor are grounded and it will discharge.
- Set the pin to input mode.
- Count how much time it takes for the capacitor to charge by waiting for the pin to go "high". This depends on the values for the capacitor and the two resistors. Since the resistors are fixed, a change in capacitance will be measurable. The distance from ground (your hand) will be the primary variable contributing to the capacitance.
We'll make this circuit at the base of each wire.
- Solder the 10k resistor to the end of the wire opposite the alligator clip
- Solder the 270k resistor between the shield and the wire (plate). We'll shield the wire with the same 5 V we use to charge the capacitors
Step 5: Finish and Attach the Connector
For me, it was easiest to solder the two outermost connectors together and then add the third.
Once you've soldered the three connectors, add a fourth wire for supplying the shield/5 V.
Step 6: Connect and Upload Code
- Plug the connector into the Arduino (pins 8, 9 and 10)
- Snap the alligator clips onto the plates (8:x:left, 9:y:bottom, 10:z:right)
- Provide power by plugging the fourth wire (my red wire) into the Arduino's 5 V
- Plug in the Arduino, start up the Arduino environment
- Upload the code to the board (note: if you are outside North America, you will probably need to change #define mains to 50 instead of 60).
Step 7: Do Something Cool!
The first thing I did with this was make a simple 3D Tic Tac Toe Interface. If you want to start with a working demo, the code is available here, just drop the folder "TicTacToe3D" in your Processing sketches folder.
Three helpful things that the Tic Tac Toe code demonstrates:
- Linearizes the raw data. The charge time actually follows a power law relative to distance, so you have to take the square root of one over the time (i.e., distance ~= sqrt(1/time))
- Normalizes the data. When you start up the sketch, hold the left mouse button down while moving your hand around to define the boundaries of the space you want to work with.
- Adding "momentum" to the data to smooth out any jitters.
Step 8: Variations and Notes
Variations
- Build massive sensors
- Optimize the resistors and code for things that vibrate quickly, and use it as a pickup/microphone
- There are probably other tricks for decoupling the system from AC hum (a huge capacitor beteween the plates and the ground?)
- I've experimented with shielding the plates on the bottom, but it only seems to cause problems
- Make an RGB or HSB color picker
- Control video or music parameters; sequence a beat or melody
- Large, slightly bent surface with multiple plates + a projector = "Minority Report" interface
Notes
The Arduino playground has two articles on capacitive touch sensing (CapSense and CapacitiveSensor). In the end, I went with an inversion of a design I stumbled across in a friend's copy of "Physical Computing" (Sullivan/Igoe) describing how to use RCtime (the circuit had the capacitor and one resistor fixed, and measured the valueof a potentiometer).
The microsecond timing was accomplished using some slightly optimized code from the Arduino forums.
Again: just from starting at tons of theremin schematics I don't completely understand, I'm well aware there are better ways to do capacitive distance sensing, but I wanted to make something as simple as possible that's still functional. If you have an equally simple and functional design, post it in the comments!
Thanks to Dane Kouttron for tolerating all my basic electronics questions and helping me understand how a simple heterodyne theremin circuit works (originally, I was going to use these -- and, if tuned correctly, it would probably be more accurate).




















































Visit Our Store »
Go Pro Today »




I did everything, but the box is not moving. what’s the problem??
Can you help me please??
I made 220K ohm by two 100k series with two 10k ( behind each other) … do you think this is the problem?
I'm trying to make this work, and it isn't working.
I loaded the code to arduino, and i load the processing code and run it, and all i get is a blank white screen. Please tell me what im doing wrong!
#define resolution 8
#define mains 50 // 60: north america, japan; 50: most other places
#define refresh 2 * 1000000 / mains
void setup() {
Serial.begin(115200);
// unused pins are fairly insignificant,
// but pulled low to reduce unknown variables
for(int i = 2; i < 14; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}
for(int i = 8; i < 11; i++)
pinMode(i, INPUT);
startTimer();
}
void loop() {
Serial.print(time(8, B00000001), DEC);
Serial.print(" ");
Serial.print(time(9, B00000010), DEC);
Serial.print(" ");
Serial.println(time(10, B00000100), DEC);
}
long time(int pin, byte mask) {
unsigned long count = 0, total = 0;
while(checkTimer() < refresh) {
// pinMode is about 6 times slower than assigning
// DDRB directly, but that pause is important
pinMode(pin, OUTPUT);
PORTB = 0;
pinMode(pin, INPUT);
while((PINB & mask) == 0)
count++;
total++;
}
startTimer();
return (count << resolution) / total;
}
extern volatile unsigned long timer0_overflow_count;
void startTimer() {
timer0_overflow_count = 0;
TCNT0 = 0;
}
unsigned long checkTimer() {
return ((timer0_overflow_count << 8) + TCNT0) << 2;
}
serial = new Serial(this, Serial.list()[serialPort], 115200);
Please help =) thank you!!
at TicTacToe3D.setup(TicTacToe3D.java:57)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
this is what it said at the bottom of the processing
I installed processing and arduino software. I upload sketch to arduino and copied Tic Tac Toe 3D to sketch folder in processing. I'm running processing and I can see window with dimensions of 7x7cm, however I don't see any any points inside the square and I'm not sure how to initialize it. Could you pls help me out? Am I missing something? Thanks a lot for any help!
its exactly the same
I have
[0] "/dev/tty.usbmodemfa131"
[1] "/dev/cu.usbmodemfa131"
[2] "/dev/tty.Bluetooth-PDA-Sync"
[3] "/dev/cu.Bluetooth-PDA-Sync"
[4] "/dev/tty.Bluetooth-Modem"
[5] "/dev/cu.Bluetooth-Modem"
from Processing.
I upload to /dev/tty.usbmodemfa131 in Arduino successfully and get good numbers out of the serial monitor there.
When I use a [0] variable for the serial port in Processing however, I get a lot of interference on the serial monitor - not gobbledygook, just weird strings of numbers if varying lengths. I just see the grey cube and nothing else happens.
When I use a [1] variable i get the following error:
RXTX Warning: Removing stale lock file. /var/lock/LK.012.018.043
gnu.io.PortInUseException: Unknown Application
and lots more.
Am I doing anything wrong?
Nice work!
I have some problems with the step 5:
I have a _3Dinterface.ino loaded in my arduino
Here if I open my serial monitor I only can see letters running
Then I open Processing program and then I open the TicTacToe3D.pde and the other 2 opens automatically. then I export my application and this creates an application with the name TicTacToe3D, when I open the app I can only see a grey screen with anything.
I'm using a Macbook pro with Mountain Lion
Can you help me please?
Thank you very much!
that's a really great example, thanks a lot!
I am trying to control 2 such controllers from one arduino, I changed interface3D.ino by adding to void loop() 3 additional lines (without really understanding, what they mean). Serial monitor now shows 5 parameteres, but the sixth one not. What does that binary number means and how could I make it work with 6 plates?
Here is the code:
void setup() {
Serial.begin(115200);
for(int i = 2; i < 14; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}
for(int i = 8; i < 14; i++)
pinMode(i, INPUT);
startTimer();
}
void loop() {
Serial.print(time(8, B00000001), DEC);
Serial.print(" ");
Serial.print(time(9, B00000010), DEC);
Serial.print(" ");
Serial.print(time(10, B00000100), DEC);
Serial.print(" ");
Serial.print(time(11, B00001000), DEC);
Serial.print(" ");
Serial.print(time(12, B00010000), DEC);
Serial.print(" ");
Serial.println(time(13, B00100000), DEC);
}
Thanks for your answer!
it will be very kind from you if you respond me actually i have done all steps thanks god and i upload the code to arduino and i am now in calibarating step i try more than one time but no response it this may be because of iam using small aliigator clips= less contact area ???
the contact area between the clips and the plates shouldn't matter. they just need to be touching.
you might want to also check this tutorial, which is for the same system but rewritten more clearly http://makeprojects.com/Project/A-Touchless-3D-Tracking-Interface/2233
serial = new Serial(this, Serial.list()[serialPort], 115200);
Has anyone solved this yet?
If you were getting that error from the serial line, you have to make sure that the serial variable at the top is the correct serial port. If you look above the error, it should show the serial port that you are using. Mine was com4 so it showed:
[0] "COM4"
Therefore in my situation I had to change the serial variable to 0.
I also got that error randomly sometimes when I would run the program. I think that came from the board sending data before the program starts receiving it and then the program starting halfway through a line. To fix this I just made sure to hit the reset button at the same time I hit run on the processing code and it solved my problem.
Hope that helped :)
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
[0] "COM3"
Does anyone know how to fix the RXTX Version mismatch ???