hey all,
i wanted to send an integer value from 1 arduino to another using cc2500 wireless module.
The thing is, when i send say 1(int value), using Serial.print(), it converts it to a string and sends it through the Tx. This is recived by the other arduinos buffer and i use
incoming=Serial.read();
to read it. now incoming has the ascii value 49(int value).
is ther any way to convert it back to 1 without predefined chartor sumtin?
in short,
i want to send interger data by Serial.print() and i want to receive it as an integer value, not the ascii equivalent.
you can just send the raw data without converting it to ascii.
int i=1; Serial.print(i,BYTE);
would send just a 1 rather than a 49.
I wouldn't worry about conversion overhead if i were you, the arduino can convert it way quicker than the serial send time. I usually use ascii where I can to make it easier to debug with a serial monitor.
If I need to transmit a multi-digit number i might use raw BYTE's to save re-parsing the ascii at the other end but that's just coding laziness on my part, not efficiency.