8 years, 5 months ago.

pc.printf problem

serial_test

#include "mbed.h"              
 
Serial pc(USBTX, USBRX);
 
int main() {
    
    int foo = 1;
    
    while(foo<=50) {
        pc.printf("Darryl %i\n", foo);
        foo++;
        wait(0.2);
    }
}

Not carriage returning properly?

http://darrylgriffiths.co.uk/terminal.png

1 Answer

8 years, 5 months ago.

Hello Darryl,

Some PC serial terminal programs require also a carriage return character ('\r') to be sent in order to work properly:

...
pc.printf("Darryl %i\r\n", foo);
....

Accepted Answer

Thanks very much, that has solved my problem.

posted by Darryl Griffiths 11 Oct 2017