views:

35

answers:

1

I've found this really cool site on interfacing an Arduino to an optical mouse to read out x-y readings from it. I've done it, and it's working nicely.

Then I was thinking, 'Why not plot all this to become a graph?' and I came across Processing.

I am aware that Processing has an example named 'MouseSignal'

This example is the EXACT thing that I want to write with Processing. But, the only change is that, I want to use the x-y coordinates from the mouse that is attached to the Arduino and ask Processing to generate a 'real-time' graph of the coordinate.

Thanks!

A: 

Change the spot in the code where it says:

xvals[width-1] = mouseX; 
yvals[width-1] = mouseY;

Replace mouseX and mouseY with the values coming from the Arduino. You may need to scale these values to fit within the axes.

wxs
I believe I need to add in import processing.serial.*;at the start as well as println(Serial.list()); g_serial = new Serial(this, Serial.list()[1], 115200, 'N', 8, 1.0); under void setup?
MH2020
If that's how you are getting the data off the Arduino, then yes you would need to do that (and also define Serial g_serial; outside of setup()). Have you looked into the official Arduino processing library instead of just the serial interface, though? http://www.arduino.cc/playground/Interfacing/Processing
wxs
I've looked at it, but don't quite understand, since I haven't tried it. Maybe I'll understand after trying it out. And thank you for getting me this far!
MH2020

related questions