wireless stepper motors

Respected sir,

Myself Manas Bose, I am working on a project, where I have to control a stepper motor step control with the help of a potentiometer, and arduino , sir I have wrote a skech with the help of a friend attached herewith, it is working fine.

now I want to make this thing wireless, sir I want to use 2 arduino and 2 xbee, on sending side a arduino, xbee, and a potentiometer will be there. On receiving side a arduino, xbee and a stepper motor will be there.
, I and my friend don't have adequate knowledge of c ++, I hereby request u to kindly help
In the coding, or at least if u can throw some light on it.

The problem now is that when pot value is transmitted to the recipient xbee (stepper motor attached), the motor is not responding and even if responds, the speed, direction, steps are erratic and slow.

And after monitoring the recipient xbee on serial monitor the data looses, although the transmitting xbee is showing full map value, and on the receiving side only getting 2 digits value.

please throw some light on this

Thanking you

#include <Stepper.h>
int current_position = 0;
const char direction_pin = 2;
const char step_pin = 3;
const char pot_pin = 1; //analog input 1
void setup()
{
pinMode(direction_pin, OUTPUT);
pinMode(step_pin, OUTPUT);
pinMode(pot_pin, INPUT);
}

void loop()
{
int  readvalue = analogRead(pot_pin);
readvalue = map(readvalue,0,1023,0,1600); 1600=200 steps
if (readvalue > current_position)
{
step_motor_forward();
current_position += +;
}
else if (readvalue < current_position
{
step_motor_back();
current_position -= -;
}
}//end of loop

void step_motor_forward()
{
digitalWrite(direction_pin, LOW);
digitalWrite(step_pin, HIGH);
digitalWrite(step_pin, HIGH);
}

void step_motor_back()
{
digitalWrite(direction_pin, HIGH);
digitalWrite(step_pin, LOW);
digitalWrite(step_pin, LOW);
}
//Sending
   int val = 0;
   int mapVal = 0;
   int potPin = 0;

   void setup()
   {
     Serial.begin(9600);
     pinMode(potPin, INPUT);
   }
   void loop()
   {
     val = analogRead(potPin);
     mapVal = map(val,0,1023,0,255);//
     Serial.println(mapVal);
Serial.write(mapVal);
delay(10);
   }
/receiving

#include <Stepper.h>
int current_position = 0;
const char direction_pin = 2;
const char step_pin = 3;
void setup()
{
pinMode(direction_pin, OUTPUT);
pinMode(step_pin, OUTPUT);
Serial.begin(9600);
}

void loop()
{

if ( Serial.available()) { 
int readvalue = Serial.read();
readvalue = map(readvalue,0,255,0,1600);
Serial.println(readvalue);

if (readvalue > current_position)
{
step_motor_forward();
current_position = readvalue;
}
else if (readvalue < current_position)// 
{
step_motor_back();
current_position = readvalue;
}


}

}//end of loop

void step_motor_forward()
{
digitalWrite(direction_pin, LOW);
digitalWrite(step_pin, HIGH);
digitalWrite(step_pin, HIGH);
}

void step_motor_back()
{
digitalWrite(direction_pin, HIGH);
digitalWrite(step_pin, LOW);
digitalWrite(step_pin, LOW);
}

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

You are sending numbers as text when you use Serial.print(). That means a number such as 123 will take three characters. Your receiving code is not designed for that - it assumes only 1 character will be received

Have a look at the examples in Serial Input Basics

Alternatively use Serial.write() which sends a byte value directly. However your code will be easier to debug if you send data as human readable text.

...R

DO NOT CROSS-POST, CROSS-POSTING WASTES TIME.

Duplicate deleted.