We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Serial problem (Read 727 times)
Serial problem
Feb 19th, 2008, 9:58pm
 
Hi,

I have difficulties with this code :

PROCESSING
import processing.serial.*;

Serial myPort;

void setup() {
 myPort = new Serial(this, Serial.list()[1], 9600);
//Always start and a communication with sending 85
 myPort.write(byte(85));
 delay(20);
 myPort.write(byte(12));
 delay(20);
 myPort.write(byte(19));
 delay(20);
 myPort.write(byte(14));
 delay(20);
 myPort.write(byte(85));
 }

ARDUINO :

void setup() {
 Serial.begin(9600);
}

void loop() {
 byte temp[100];
 byte tampon;
 int i=0;
 if (Serial.read()==byte(85)) {
   while((tampon=Serial.read())!=byte(85)) {
    temp[i]=tampon;
    Serial.print(i);
    delay(20);
    Serial.print(temp[i]);
    i++;
   }
 }
 //Serial.print(85);
}


I don't know if it is  problem of synchronisation but when i monitor the serial port i can't see what i writed...

Any idea ? or a good tutorial on serial communication...
Re: Serial problem
Reply #1 - Feb 19th, 2008, 11:01pm
 
do you see anything?

do you get any errors in processing?

which model of arduino are you using?

It could be because you are only sending the info once in setup - if you using a diecimiellia arduino on a mac opening the serial port will cause the board to reset and there is a delay before the code on the board runs after that, so your setup function will send the info while the board is resetting and it will miss it.

Try putting a delay of a couple of seconds after you open serial port and see if that helps
Page Index Toggle Pages: 1