Go Down

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

PaulS

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.

jifei

hi paul

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

PaulS

It did, but only very briefly, since, once the process repeated, the light was turned back on.

jifei

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?

jifei

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;
    myPort.write(sta);
    println(sta);
  }

it works perfectly now
:)

PaulS

Quote
it works perfectly now

It worked for me without that change, but, I'm happy that it works for you now.

Go Up