DIY 3D Controller

Step 7Do Something Cool!

If you look at the serial window in the Arduino environment, you'll notice it's spitting out raw 3D coordinates at 115200 baud, at approximately 10 Hz = 60Hz / (2 full cycles * 3 sensors). The code takes measurements as many times as possible on each sensor over the period of two cycles of the mains power frequency (which is suprisingly stable) in order to cancel out any coupling.

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.

In practice, using this setup with aluminum foil I can get a range of the largest dimension of foil (the biggest piece I've tested is 1.5 square feet).
« Previous StepDownload PDFView All StepsNext Step »
9 comments
Jan 31, 2012. 10:29 PMpierceRom says:
Hi there !!! im totally new at this whole electronics thing and I wanna try this project but i ran into a bit of problem.

I have built the board and everything but my problem is with the code. Where exactly is the code for the arduino ?? Or is the program " Processing" code suppose to upload the code into the arduino ?? Sorry if this question seems noob but im really new at this =(

Thank you soo much for any help !!
Feb 1, 2012. 7:48 AMpierceRom says:
Thank you sooo much for the quicky reply !! So the interface code goes into the Arduino and the TicTacToe code goes into Processing ??

But shouldnt there be a camera in the code somewhere so i can interact with the TicTacToe game in 3d ??? Where would that code be ??

Sorry once again if my questions seems completely retarded , im really new at all this unfortunately =
Feb 2, 2012. 5:46 PMpierceRom says:
Last question i promise !!

It seem that there were two files " Interface" and "Tic Tac Toe " in the download section .

So the interface code goes into the Arduino board and the TicTacToe code goes into Processing ??

Sorry but could you clarify that a little bit ??? Many many thanks for your help !!

Cheers

Pierce
May 20, 2011. 5:10 PMavillanueva1 says:
I had problems with the code, the processing tell me that i have an error ArrayIndexOutOfBoundsException 2, am i doing something wrong?
Jun 11, 2011. 8:47 AMjimmy dean says:
I am also getting the same error. It is pointing to this line in setup:

serial = new Serial(this, Serial.list()[serialPort], 115200);

Has anyone solved this yet?
Jun 11, 2011. 9:11 AMjimmy dean says:
Ok, I figured it out.

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 :)
Jul 23, 2008. 7:36 PMrct1113 says:
yeah, it can be hard to post on Gizmodo, they're all uptight on new posters, but I think that if you sent them a note saying that it's you're 'structible, then I think they'll let you in. Tell us what it's like on "the other side". ;)

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!
103
Followers
6
Author:kylemcdonald