Formatted strings to serial port plus flashing led

Dependencies:   mbed

main.cpp

Committer:
MarkAntony
Date:
2018-07-09
Revision:
0:dce6037f5901

File content as of revision 0:dce6037f5901:

#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);
    }
}