Hi,
I am trying to send float values from my K64F to the android app using mbed. The Arduino code which I am referring is using
Serial blue(PTC15, PTC14); while (true) { blue.print(Val) val = val + 1 ; }
But I am unable to use the “print” function in mbed. How to use it? I tried sprintf and printf (Not helping).
I don’t want to visualize all the values being sent. The latest value is what I wanted to see. Can anyone help me with this?
Here’s the Mbed Serial API documentation. You’ll want to use printf, but you need to format the string in the following way, assuming that val is an integer and you’re delimiting by CRLF.
blue.printf("%i\r\n", val);
Also, in your code Val in the line blue.print(Val) has a capital V. Below that you increment val, with a lowercase v.
Ahoj, print is not a member of Serial.h, how wrote Adam, use the printf.
When you want to send a float type, you need to format it first because the output on opposite side is represented as a string type.
So if the variable val is int type then blue.printf("%d\r\n", val);
but when the variable val is float type then blue.printf("%f\r\n", val);
Hi,
Yes, I was able to fix it.
Now I have to send two values but they should come up in separate text boxes in my android app.
For example:
int val = 200;
int result = 2;
blue.printf(“%d”, val); - > In android display, it should come on first field(text box)
blue.printf(“%d”, result); - > In android display, it should come on second field(text box)
Thanks and Regards
Niranjan