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
Problem with serialevent (Read 752 times)
Problem with serialevent
Feb 12th, 2008, 9:34pm
 
Hi !

I've a problem by using Serialevent.

Here is the code :

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

void loop() {
Serial.print(85);

}

PROCESSING :

Serial myPort;
 myPort = new Serial(this, Serial.list()[1], 9600);

void serialEvent(Serial p) {
if(p.read()==85) {
   carte_libre=1;
   print("pet");
   
   //on supprime les données ! A FAIRE
 }
}

I tried to change p for myPort etc. Whats wrong with this code ?

JB

Re: Problem with serialevent
Reply #1 - Feb 12th, 2008, 9:37pm
 
Okay sorry, was trying to compare a int and a char...
Re: Problem with serialevent
Reply #2 - Feb 12th, 2008, 9:58pm
 
I still have a question :

How can i store an array of data sent from Processing to Arduino. I tried this :

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

void loop() {
 byte temp[100];
 int i=0;
//Processing send 85 when ready to send datas
 if (Serial.read()==85) {
//store all the data in an array
//i send an array of byte
//myPort.write(array_of_byte);
   while(Serial.available()) {
     temp[i]=byte(Serial.read());
     i++;
   }
 }
  //Send 85 to Processing when ready to receive another datas
 //Serial.print(85);
}



Page Index Toggle Pages: 1