i'm working in a code which receive a number via bluetooth and then print it to the serial monitor but it shows the ascii code of the number,,,,so i substract '0' but still wrong cause it replace "." by "-2"
so for example if i send 1.3 it will be 1-23 in the serial monitor
any help??
Always post the code that is not working for you. And expected + actual output. Do you want to display ascii code of the characters or something else? It's not clear from your post.
You should not need to convert it if you read it correctly.
aeternus
The character '0' is 48 decimal. If you subtract '0' from it you get zero. The ascii code for '.' is 46 decimal so subtracting '0' from it gives you -2.
You aren't displaying the received characters properly. You don't have to convert the characters to binary.
Instead of Serial.print(c-'0') just use Serial.print(c);
Pete
no i want the actual number
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available()>0)
{
Serial.print(Serial.read());
}
}
i send number as a text from a mobile application like (1.3)
the expected result in the serial monitor is 1.3
the output was 494651 " which is the ascii code of 1.3"
so i want to convert it to 1.3 in the serial monitor
What will show up when you use this?
if(Serial.available()>0)
{
Serial.write(Serial.read());
}
aeternus
it works perfectly (Y)
thank you