Go Down

Topic: Serial communication (Read 499 times) previous topic - next topic

brenin

Jul 07, 2008, 03:47 pm Last Edit: Jul 07, 2008, 03:48 pm by brenin Reason: 1
Hello,

I'm experiencing a little problem with the serial communication (ARDUINO + PROCESSING) with my arduino BT. The processing program only works properly if I reset the arduino just after a play the processing code. My doubt is: is there a way of doing that communication works without  being necessary to reset the arduino?
The part of the code that makes the communication is the following (based in the examples of the arduino)

Code: [Select]

void draw() {
 while (port.available() > 0){
     serialEvent(port.read());
 }
 println ("value: "+val);
}
void serialEvent(int serial)
{
 if(serial != NEWLINE) {
   buff += char(serial);
 } else {
   buff = buff.substring(0, buff.length()-1);
   val = Integer.parseInt(buff);
   buff = "";
 }
}


In the arduinoBT I'm using the Serial.print(), with a delay of 100 between  two messages.

If I don't push the reset button, the processing just prints "value: 0".

Any ideas?

My arduino is the BT-06, with processing-0135 in Windows XP SP2

Rafael Quines

Hi..

I think this is caused by boot routine in your ATMEGA.

Try wait about 3 seconds before listen Serial port. Wait this 3 seconds before Serial.Begin command.

I think it will work.

rafaelquines@gmail.com
http://arduinors.net
http://rafaelquines.com

Go Up