![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Formatted strings to serial port plus flashing led
Diff: main.cpp
- Revision:
- 0:dce6037f5901
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jul 09 23:17:01 2018 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); // tx, rx +DigitalOut MyLed1(LED1); + +int main() +{ +pc.baud(9600); + while(1) { + printf ("Characters: %c %c \n\r", 'a', 65); + printf ("Decimals: %d %ld\n\r", 1977, 650000L); + // Reverse video: + //printf ("\033[7m"); + printf ("Preceding with blanks: %10d \n\r", 1977); + printf ("Preceding with zeros: %010d \n\r", 1977); + printf ("Some different radixes: %d %x %o %#x %#o \n\r", 100, 100, 100, 100, 100); + printf ("floats: %4.2f %+.0e %E \n\r", 3.1416, 3.1416, 3.1416); + printf ("Width trick: %*d \n\r", 5, 10); + printf ("%s \n\r", "A string"); + //Clear screen upwards + //printf ("\033[1J"); + MyLed1 = !MyLed1; + wait(1.0); + } +} \ No newline at end of file