We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am stuck trying to send 3 analog values (potentiometer inputs) from arduino into processing. the values are 0-1023 (10bit)... I cant figure out how to do it.. as a test sketch I tried this for the arduino side:
void setup()
{
Serial.begin(9600);
}
void loop()
{
int a = -11023;
int b = 564;
int c=analogRead(0);
Serial.println(a);
Serial.print(",");
Serial.print(b);
Serial.print(',');
Serial.print(c);
Serial.print(',');
delay(500);
}
and this for processing:
import processing.serial.*;
Serial myPort;
int value;
void setup()
{
myPort = new Serial(this, Serial.list()[0], 9600);
}
void draw()
{
}
void serialEvent(Serial p) {
// get message till line break (ASCII > 13)
String message = myPort.readStringUntil(',');
if(message != null){
value = int(message);
println(value);
}
}
All I get are zeros on the serial monitor... The idea is to ultimately send data to processing in groups of 3 (for the 3 sensors) and assign them to 3 variables in processing but I can see Im not grasping the concept of serial transmission :(
Answers
Hi,
http://www.arduino.cc/en/Tutorial/VirtualColorMixer
watch the processing code just below commented or in arduino ide: file-->example-->communication--> VirtualColorMixer and see the processing sketchDunno whether that's the problem, but you're not using serialEvent()'s parameter -> p.
Rather the "global" variable myPort inside serialEvent(). :|
Actually AFAIK, you can get rid of that useless myPort variable from your sketch! =;
Lest not to get into temptation of using that in the wrong places: :-\"