We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone,
I have the following arduino code:
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.println("hello");
delay(50);
}
and processing:
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
void setup()
{
size(200, 200);
// I know that the first port in the serial list on my mac
// is always my FTDI adaptor, so I open Serial.list()[0].
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
println(Serial.list()[9]);
String portName = Serial.list()[9];
myPort = new Serial(this, portName, 9600);
myPort.clear();
}
void draw()
{
while( myPort.available() > 0) { // If data is available,
val = myPort.read(); // read it and store it in val
//println(val);
int lf = 10;
String v = null;
v = myPort.readString();
if(v != null){
println(v);
}
}
}
I am expecting processing to be printing out "hello", but it ends up looking like this
> o
>
> el
> o
>
> ello
> ello
>
>
> ell
>
>
> el
> o
>
> e
> lo
>
> ello
>
>
> ell
>
>
> el
> o
Any ideas what is going on here?
Answers
I'm not sure why, but changing the code to follow this http://processing.org/discourse/beta/num_1272968810.html old post works for me in printing "hello". But the SimpleRead example doesn't work as shown above. Very bizarre.