Hi guy, i m currently doing a project that requires me to transmit and receive int values throught Tx and Rx. I went online and follow some examples but instead of receiving int values , i m receiving weird hex and chars.
Btw, i m using Arduino UNO and hope to send more than one value.
Code:
void loop() {
int val1 = map(analogRead(flex1),270,70,0,255);
Serial.write(val1);//Sender
if(Serial.available())
{
int val3=Serial.read();//Receive
Serial.println(val3);//Check whether it is correct
}
}
Thank you
Hi HappyKevin
You are using the same (single) serial port to send and receive the integer values and display the test results.
What do you have connected to the serial port?
Regards
Ray
PS please use code tags when posting code - the </> button on the toolbar.
Hi,
We will need to see your complete code, what speed do you have the serial set for, and is it the same as the speed of the monitor window?
Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html
Tom.... 
Sorry, here is my full code.
int flex1 = A0;
int val1 = 0;
int val3 = 0;
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
}
void loop() {
val1 = map(analogRead(flex1), 270, 70, 0, 255);
Serial.write(val1);
if (Serial.available())
{
val3 = Serial.read();
Serial.println(val3);
}
// put your main code here, to run repeatedly:
}
TomGeorge:
Hi,
We will need to see your complete code, what speed do you have the serial set for, and is it the same as the speed of the monitor window?
Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html
Tom.... 
Yes both arduino and serial montior are set at 9600 baud rate
Hackscribble:
Hi HappyKevin
You are using the same (single) serial port to send and receive the integer values and display the test results.
What do you have connected to the serial port?
Regards
Ray
PS please use code tags when posting code - the </> button on the toolbar.
I m using digital pin 1 and 0. i m just using a jumper wire to connect pin 0 and 1
Serial.write sends binary values, which will be printed as various characters on the monitor and the result is not easy to interpret.
What do you want your program to do?
I m trying to send flex sensors reading on one arduino to another another arduino via xbee module.
So i thought of trying to do a loop back first b4 proceeding to xbee
Hi,
I m using digital pin 1 and 0. i m just using a jumper wire to connect pin 0 and 1
You don't need to jumper anything.
Just open the monitor in the IDE.
If you are shorting 0 to 1, then you are shorting the Rx/Tx together.
Just leave the UNO plugged in the same way you program it, it will using Serial, comm back through the cable, no jumpers required.
Tom..... 
Your idea is fine, except that you cannot attach USB and loopback (shortcut) to the same serial port. If you have e.g. a LCD display, output the diagnostic messages there.
And don't forget to remove the loopback shortcut when programming the Uno!