perhaps I didn't explain it well enough =/
The way I'm introducing is really different from the previous way you were doing it (I find this easier because I'm more of a software person than a hardware person)
The Arduino should have the firmata sketch loaded. To do this, download:
http://www.arduino.cc/playground/uploads/Interfacing/processing-arduino. zip
and unextract it.
In the arduino IDE, open the file in the path arduino/firmware/Standard_Firmata/Standard_Firmata.pde
Now upload this sketch to your Arduino board. Basically, the Firmata sketch allows processing to access the Arduino board over the serial bus and query the digital/analog sensors (among another things).
-That's it for the Arduino programming - nothing left to do with the Arduino.
Now on the processing side, try this sketch (I just tested it and it seems to work):
Code:
import processing.serial.*;
import cc.arduino.*;
int analogPin = 5;
int analogValue = 0;
Arduino arduino;
void setup(){
println(arduino.list());
arduino = new Arduino(this, Arduino.list()[1], 57600);
}
void draw(){
analogValue = arduino.analogRead(analogPin);
int inByte = int(map(analogValue,0,1023,0,255)); //I'm mapping the analogSensor values (0-1023) to values between 0-255 like you originally wanted =]
println(inByte);
}
I tried to preserve the variable names you used in your previous example - I tested this with a potentiometer hooked up to analog input 5 on the arduino and it worked just fine.
Lemme know how that works for you =] - hope it helps
cheers,
-Jeff
PS: in the arduino script in your .png, you have a line that reads:
analogValue = analogValue / 0.39
why is that? analogRead() returns 10-bit resolution values between 0-1023, so wouldn't dividing by 0.39 map your values between 0-2623 instead of 0-256 like you want?
EDIT: figured out how to use the CODE tags =]