Go Down

Topic: problem with commnunicating arduino with processing (both sending and receiving) (Read 3173 times) previous topic - next topic


I copied your processing sketch to the Processing IDE.

I copied your Arduino code to to the Arduino IDE. I compiled and linked it for my Mega, since that was handy. I uploaded it.

I started the Processing application, and watched the Processing application receive nothing from the Arduino.

I tried making a bunch of changes to both apps. No luck getting the Mega to do anything other than light the LED on pin 13 regardless of what was sent.

I unplugged the Mega, and plugged a Duemilanove in, and removed all of my changes to the Arduino code. I kept the change to the Processing code, that showed that the serialEvent method had been called, and everything worked.

The snakes stop moving when they hit the right wall, and start over.

Why this works for me on a Duemilanove, and not for you, and why is does not work for me on a Mega is a mystery.
The art of getting good answers lies in asking good questions.


hi paul

did the led on pin 13 turn off when the snake start over?


It did, but only very briefly, since, once the process repeated, the light was turned back on.
The art of getting good answers lies in asking good questions.


you mean, you use the code i posted and it works ?

What I want to achieve is, when the snake hit the edge, it will restart from left side, and hold for 3 seconds, during which the led will be on. and then the LED will be off until the snake hits the edge again

It works exactly like this?


hi paul,

the problem is that processing keep sending values to arduino, the queues is getting bigger and bigger.

i added this

int lastState = -1 // declare this before setup();

  if(mover[0].putAhold == true) {
    sta = 1;
  else {
    sta = 3;
  if(lastState != sta) {
    lastState = sta;

it works perfectly now


it works perfectly now

It worked for me without that change, but, I'm happy that it works for you now.
The art of getting good answers lies in asking good questions.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131