Pages: 1 [2]   Go Down
Author Topic: problem with commnunicating arduino with processing (both sending and receiving)  (Read 1110 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi paul

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: November 10, 2011, 11:55:26 am by jifei » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
smiley
« Last Edit: November 10, 2011, 12:54:45 pm by jifei » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: 1 [2]   Go Up
Jump to: