transfering data via bluetooth

Hey

I am working on a project where I want to send multiple values via bluethooth.
but now I'm having a problem, if I forward a character or a number, I get the numbers and characters in dec on the receiver.
now the question is, how do I change this back to characters and normal numbers?
as an example. if I send 49 I get 5257 on the receiver.

so when I send (, x49, y49) I get (441205257441215257).
how do I convert it back to chars. and big numbers.

thanks in advance

so when I send (, x49, y49) I get (441205257441215257).

WHY would you print the values receivedwithoutanyspacesbetweenthem?

Doesn't that make it way more difficult to understand what you are getting?

Look at any ASCII table. 52 and '4' are the SAME value. If you assign 52 to a char variable and print it, you'll see a '4'. If you assign '4' to an int variable, and print it, you'll see 52.

So, therein lies a clue.

It depends also on whether you send a char or a byte. 4 as a char is 52, as a byte it's 4. Print sends characters as it assumes the value to be interpreted as ASCII. Write sends bytes.

JazzJackRabbit:
if I forward a character or a number,

What you really want is far from clear. "Forwarding" a character is novel to the point of being unique. If you Serial.printed your values like most everybody else does, you might get a desired result.

Add 48 on the receiver side make a small function which will check if its in ascii number then change it adding 48. Note its only if you are sending numbers.

DKWatson:
It depends also on whether you send a char or a byte. 4 as a char is 52, as a byte it's 4. Print sends characters as it assumes the value to be interpreted as ASCII. Write sends bytes.

PaulS:
WHY would you print the values receivedwithoutanyspacesbetweenthem?

Doesn't that make it way more difficult to understand what you are getting?

Look at any ASCII table. 52 and '4' are the SAME value. If you assign 52 to a char variable and print it, you'll see a '4'. If you assign '4' to an int variable, and print it, you'll see 52.

So, therein lies a clue.

I've tried both, but with (Serial.print or Serial.write) I get the same on the receiver.

I let the receiver search for the comma, then he looks if it is x or y, then he fills in the next value at int.X or int.Y.

sorry for my orthography, but I'm from the Netherlands, I'll translate it via google translate.

Our replies to your post were a (failed) attempt to get you to POST YOUR CODE.

You are, apparently, storing what should be char data in int variables. Store the char data in char variables, and you WILL see a difference when you print the data.

PaulS:
Our replies to your post were a (failed) attempt to get you to POST YOUR CODE.

You are, apparently, storing what should be char data in int variables. Store the char data in char variables, and you WILL see a difference when you print the data.

I'm sorry, I've tried it several times, but now it does work.

Thank you

120 0 X0 Y0
49 0 X0 Y0
44 121 X0 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 121 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
44 120 X49 Y50
50 0 X49 Y50
44 120 X121 Y50
50 0 X121 Y50
0 0 X121 Y50
44 121 X121 Y44
121 0 X121 Y44
50 0 X121 Y44
120 0 X121 Y44
49 0 X121 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
0 0 X49 Y44
120 0 X49 Y44
49 0 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
0 0 X49 Y44
120 0 X49 Y44
49 0 X49 Y44
0 0 X49 Y44
120 0 X49 Y44
44 120 X49 Y44
0 0 X49 Y44
0 0 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X44 Y44
0 0 X44 Y44
120 0 X44 Y44
49 0 X44 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
44 120 X49 Y44
76 0 X0 Y0
41 0 X0 Y0
201 0 X0 Y0

I now have a problem with the signal.
it goes well at the beginning, but if I change the input value it goes wrong.

I have already played with the delay values.

I'm hunting for a picture of an answer. If you need help before the 12th of never, POST YOUR CODE AS TEXT, not stupid pictures.

When there is a byte of serial data to read, it is NOT OK to read more than once.

//MASTER

int Xval=0;
int Yval=0;
int X=A0;
int Y=A1;

void setup() {
pinMode(X,INPUT);
pinMode(Y,INPUT);
Serial.begin(9600);

}

void loop() {
if(Serial.available()>0){

}
Xval=analogRead(X);
Yval=analogRead(Y);
Xval=map(Xval,0,1023,1,100);
Yval=map(Yval,0,1023,1,100);
Serial.write (",");
Serial.write ("x");
Serial.write (Xval);
Serial.print (",");
Serial.print ("y");
Serial.write (Yval);
delay(10);

}

//SLAVE

#include <Servo.h>
int state=0;
int state1=0;
int X=0;
int Y=0;
Servo servoX;
Servo servoY;

void setup() {
servoX.attach(3);
servoY.attach(4);
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0){
state=Serial.read();
if (state==44){
state1=Serial.read();
if (state1==120){
X=Serial.read();
}
else if (state1==121){
Y=Serial.read();
}
else{
state=0;
state1=0;
}
}
servoX.write(X);
servoY.write(Y);
Serial.print(state);
Serial.print("\t");
Serial.print(state1);
Serial.print("\t");
Serial.print("X");
Serial.print(X);
Serial.print("\t");
Serial.print("Y");
Serial.println(Y);
state=0;
state1=0;
}
delay(10);
}

  if(Serial.available()>0){
    state=Serial.read();
    if (state==44){
    state1=Serial.read(); 
    if (state1==120){
    X=Serial.read();
    }

So, the ',' arrives. You store that character in a variable (stupidly) named state. That character is a comma (which is what you should have compared to), so you read a byte that hasn't arrived yet. Does that REALLY seem like a good idea?

PaulS:

  if(Serial.available()>0){

state=Serial.read();
    if (state==44){
    state1=Serial.read();
    if (state1==120){
    X=Serial.read();
    }



So, the ',' arrives. You store that character in a variable (stupidly) named state. That character is a comma (which is what you should have compared to), so you read a byte that hasn't arrived yet. Does that REALLY seem like a good idea?

I do not know very much about programming arduino.
what is the best way to do it?

what is the best way to do it?

Follow the example of someone who knows what they are doing:
http://forum.arduino.cc/index.php?topic=396450.0