Sending Data from Computer (using processing ide) to Arduino using XBee

Hi Guys,

I am currently doing a project where i am trying to send the “acceleration” and “distance to move to” values from my computer using Processor IDE to my arduino Mega using XBee Series one. As i have no prior experience whatsoever with programming or robotics, i am not able to even verify the program.

I am trying to send 6 values over to the arduino so as to control my stepper motors so as to allow my robot to move. Any kind souls can help me out here?

Below is my processor code

import processing.serial.*;

Serial comPort;

int d1 = -1250;
int v1 = 250;
int d2 = 2500;
int v2 = 500;
int d3 = -1250;
int v3 = 250;

void setup(){
  comPort = new Serial(this, Serial.list()[0], 9600);
}

void draw() {
  comPort.write(d1);
  comPort.write(v1);
  comPort.write(d2);
  comPort.write(v2);
  comPort.write(d3);
  comPort.write(v3);
  
}

Below is the Arduino Code

#include <SoftwareSerial.h>
#include <AccelStepper.h>

// Define three steppers and the pins they will use
AccelStepper stepper1(1, 3, 2);
AccelStepper stepper2(1, 9, 8);
AccelStepper stepper3(1, 12, 11);
int d1, v1, d2, v2, d3, v3;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  stepper1.setMaxSpeed(1000);
  stepper2.setMaxSpeed(1000);
  stepper3.setMaxSpeed(1000);
}

void loop() {
  // put your main code here, to run repeatedly:
   if (Serial.available()) 
   { // If data is available to read,
     d1 = Serial.read(d1);
     v1 = Serial.read(v1);
     d2 = Serial.read(d2);
     v2 = Serial.read(v2);
     d3 = Serial.read(d3);
     v3 = Serial.read(v3);
     
   }
  delay(100); // Wait 10 milliseconds for next reading
  
  stepper1.setAcceleration(v1);
  stepper1.moveTo(d1);
  stepper2.setAcceleration(v2);
  stepper2.moveTo(d2);
  stepper3.setAcceleration(v3);
  stepper3.moveTo(d3);
  
  if (stepper1.distanceToGo() == 0)
        stepper1.stop();
  if (stepper2.distanceToGo() == 0)
        stepper2.stop();
  if (stepper3.distanceToGo() == 0)
        stepper3.stop();
  stepper1.run();
  stepper2.run();
  stepper3.run();
}