Proccessing-Arduino Joystick issues (updated)

NOTE: I have edited this post from the original. Sorry, but some of these replies may not make sense. Next time I’ll start a new one instead.

Okay, so I am working on getting processing communicating with my arduino which has a claw-machine style joystick attached.
I’ve gotten the sketches to work, but there’s one minor problem.
It is supposed to be a black circle that moves according to the joystick, and turns yellow when the button is pressed.
This all works, but there is a ~5-6 second pause after opening the processing applet to when it responds to the joystick.
Is this normal?
Processing code:

import processing.serial.*;

int xPos;
int yPos;

Serial arduino;


void setup() {
  size(320,240);
  ellipseMode(CENTER);
  String portName = Serial.list()[0];
  arduino = new Serial(this, portName, 57600);
}

void draw() {
  background(255);
  int push = pressed();
  int coord = getCoor();
  if(push == 1)  {
    fill(255, 255, 0);
  }
  else  {
    fill(0);
  }
  switch(coord)  {
  case 1:
    xPos -= 5;
    yPos -= 5;
    break;
  case 2:
    yPos -= 5;
    break;
  case 3:
    xPos += 5;
    yPos -= 5;
    break;
  case 4:
    xPos -= 5;
    break;
  case 6:
    xPos += 5;
    break;
  case 7:
    xPos -= 5;
    yPos += 5;
    break;
  case 8:
    yPos += 5;
    break;
  case 9:
    xPos += 5;
    yPos += 5;
    break;
  }
  xPos = constrain(xPos, 0, width);
  yPos = constrain(yPos, 0, height);
  ellipse(xPos, yPos, 15, 15);
  delay(10);
}

int getCoor()  {
  int res;
  long time = millis();
  arduino.write('c');
  while(arduino.available() == 0  && time > millis()-1000)  {
  }
  return arduino.read();
}

int pressed()  {
  int res;
  long time = millis();
  arduino.write('b');

  while(arduino.available() == 0  && time > millis()-1000)  {
  }
  return arduino.read();
}

Arduino code:

byte req;

byte crossGet()  {
  byte coor = 5;
  if(digitalRead(4) == HIGH)  {
    coor += 3;
  }
  if(digitalRead(6) == HIGH)  {
    coor -= 3;
  }
  if(digitalRead(5) == HIGH)  {
    coor --;
  }
  if(digitalRead(3) == HIGH)  {
    coor ++;
  }
  return coor;
}

byte pressed()  {
  byte res;
  if(digitalRead(7)==LOW)  {
    res=1;
  }
  else  {
    res=0;
  }
  return res;
}

void setup()  {
  for(int i=3; i<=7; i++) {
    pinMode(i, INPUT);
    digitalWrite(i, HIGH);
  }
  pinMode(2, OUTPUT);
  digitalWrite(2, LOW);
  Serial.begin(57600);
}


void loop()  {
  req = 'n';
  if(Serial.available()>0)  {
    req = Serial.read();
    if(req == 'c')  {
      byte coor = crossGet();
      Serial.print(coor, BYTE);
    }
    else if(req == 'b')  {
      byte press = pressed();
      Serial.print(press, BYTE);
    }
  }

}

Any ideas?
Thanks

This problem is similar to your previous one. If you remove ",DEC" from print you should get better results.

Alternatively, you could modify the Processing side to use strings or characters instead of integers.

In other words, pressed currently returns 0x30 or 0x31 (ASCII zero or one). This change should also work but I don't recommend it because it will be difficult to understand later...

void draw() {
  int push = pressed();
  print(push);
  if(push == [glow]0x31[/glow])  {

BTW, you're allowed to:

int getCoor()  {
  arduino.write('c');
  while(arduino.available() == 0)  {
  }
  return arduino.read();
}

I updated the problem after I solved the old one.
Also, I am having trouble exporting it as an application (just because I wanted to try it). The applet appears in my dock, but no window opens.

I updated the problem after I solved the old one.

Please don't do that. Now the responses that were posted don't make any sense.

Someone searching this forum will be left scratching their heads wondering what the responses have to do with the problem statement.

Please put the original text back, if you can. Then, either start a new thread or describe the new problem in a new reply.

Okay, sorry. I don't have the original text, so should I remove my first post?

so should I remove my first post?

Then we’d look like a bunch of idiots talking to ourselves. No, don’t do that. Just make it clear in the first post that you edited it.

I put a notice that will hopefully be obvious saying that I edited the original. Sorry for any confusion I may cause, next time I will start a new topic. :-[