Arduino Xbee Wireless Car

Hello everyone,

I am having trouble writing some code for my Electrical engineering project and need some help.
So far i have a code that will tell me what the Arduino Nano on the car receives, and it gets sent back to my computer.

This is Setup by having a Xbee S1 hooked up to my laptop with a Xbee explorer, that is communicating with another Xbees S1 that is on a Arduino Nano Shield. On the car is self there is an H-Bridge for power to the motors, and battery pack.

This is the code for what i have so far. The only command that i have going so far is to make the car go forward, because once i figure one out i can do the rest out.

//XCTU W = 119 Recieved
//XCTU S = 115 Recieved
//XCTU A = 97 Recieved
//XCTU D = 100 Recieved

int incomingByte = 0;// H Bridge code for the pins into the H Bridge
int in1 = 2;
int in2 = 3;
int enA = 5;

int in3 = 4;
int in4 = 7;
int enB = 6;
void setup() {
  Serial.begin(9600);

  //HBridge
  pinMode(in1,OUTPUT);
  pinMode(in2,OUTPUT);
  pinMode(in3,OUTPUT);
  pinMode(in4,OUTPUT);

  pinMode(enA,OUTPUT);
  pinMode(enB,OUTPUT);
 

}
void loop() {
  // put your main code here, to run repeatedly:

if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();

                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte, DEC);
 
int getData = Serial.read();  //read the serial port
delay(100);
  if (getData == 119){
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(100);}
  }
  }

Clearly state the format of communication from your PC to arduino. You've provided no description of commands and their actions. I suspect you serial read one too many times but you said nothing about how you are communication.

The way i am communicating from PC to Arduino is XCTU, which can send data to the arduino.

I have code in the arduino, so when i hit 'w' XCTU says that 77 was sent to the other Xbee on the Arduino, and the arduino sends back that " I received : 119"

Every time you read the serial port, one character is removed permanently. So if you first read the 'w' into incomingByte, and then try to read again with getData. getData will NOT read w anymore. You shouldn't read serial port a second time. You should change your comment. Not W, w.