Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 1 month ago.
Can you help me?
Hi!, I create a program with the serial communication, i think it is right, but it doesn't work, this is the Program, what is the problem?
- include "mbed.h"
- include "SRF05.h" SRF05 ultra(D7, D8); Serial pc(USBTX, USBRX);
int main() { while(1) { pc.printf("Distance:", ultra.read()); wait(0.2); } } The serial read just "Distance"..
Question relating to:
1 Answer
11 years, 1 month ago.
You need to tell it where to print the variable, as is done in the example program this question is linked to.
printf("Distance = %.1f\n", srf.read());
The %f means it should print a float on that location, and the .1 means it should have one decimal after the decimal separator.