Instructables

Step 7: Do 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).
 
Remove these adsRemove these ads by Signing Up
Ramzeez1005 months ago

Hi, I realize this comment may be a bit late, but I'm a bit new to Arduino and I was trying to get this to work. I'm using an Arduino Uno, which Make Magazine used, and I fixed the processing code and got everything uploaded and running. When I run the TicTacToe3D program from processing I am able to see the grey cubes and the red ball, but when I place my hand in while left click holding the window, nothing happens except for the program saying "defining boundaries". Any help?

Hi,
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!
TomB221 year ago
Hi
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!
royshearer1 year ago
Does the serial port numbering array work in the same way in mac OSX?
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?
phammer1 year ago
Hi I have got the thing up and running with the problem that when running the processor the gray box appears instead of the cubes and when I move my hand the grey box moves with my hand instead. Any solution for this?
samblam2 years ago
Hi there,
I just made the 3d controller and im now trying to make it work. Im new to processing so when I tried to 'just drop the folder TicTacToe3D' in the folder I found under sketch->show sketch folder it wasnt opening. so i just dragged the 3 .pde files on the screen and pressed Run.

This gave an error
in line 54: if(parts.length == sensors) {

'Cannot find anythin named "sensors"'

Does anyone know what is the problem and what is the solution?

Thanks,
kylemcdonald (author)  samblam2 years ago
yes, it looks like that's a bug with the code. i'm not sure how it got there, sorry!

change "sensors" to "sen" and it should run.
Thanks a lot, it's working now. Awesome!
pierceRom2 years ago
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 !!
kylemcdonald (author)  pierceRom2 years ago
there is a link to the arduino code at the bottom of step 6. good luck!
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 =
kylemcdonald (author)  pierceRom2 years ago
hey, you're welcome -- the delay in my response to a question is usually exponentially proportional to the complexity of the response, so the easy ones get answered fast :)

there is no camera involved here -- you just need to look at your hand :)

if you want to get a camera involved, you'll have to hack the processing sketch.

for the video i posted, i recorded the camera separately and composited them afterwards, just for demoing how things worked.
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
I had problems with the code, the processing tell me that i have an error ArrayIndexOutOfBoundsException 2, am i doing something wrong?
rct11136 years ago
kylemcdonald (author)  rct11136 years ago
Thanks for the note -- I tried replying to some of the comments there, but they have yet to post my comment. Alas.
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". ;)