Help!!! need transmit/receive code

Currently i am building a remote control using 2 arduino Arduino 1 for transmitter Arduino 2 for receiver

i want to send joystick position data using the transmitter and the receiver should get the data and output as PWN

i am wondering how to write the code to send and get the data i am confusing with the data type

That's wht i think(not a completed code)

for transmitter

byte joyValue=0;

joyValue= map(analogRead(0),0,1023,0,127);

Serial.print(joyValue, BYTE);

for receiver

int inByte;

inByte = Serial.read();

digitalWrite(6,inByte);

is it going to work? if i sent one byte at a time, can the receiver save that byte as integer value?

thank you :D

If you want to output as PWM you need to do analogWrite.

Also, don't forget that the receiver needs to wait until a character is available in the serial port before reading, see: http://www.arduino.cc/en/Serial/Available

Not sure whay you only map to 127, you could map the full 0-255 values that analogWrite can handle.

Have fun!

thanks but i want to know is that ok using the Serial.print(joyValue, BYTE) to send the signal through Xbee pairs

and the receiver will store this value using int inByte=Serial.Read();

so if joyValue =255 , i will get inByte=255.

is that right?