Print on PC example.

Dependencies:   mbed

Committer:
bcostm
Date:
Sat Jul 08 05:01:19 2017 +0000
Revision:
1:ce08f1d8140c
Parent:
0:0ee4748f4c5c
Add comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:0ee4748f4c5c 1 #include "mbed.h"
bcostm 0:0ee4748f4c5c 2
bcostm 1:ce08f1d8140c 3 /*------------------------------------------------------------------------------
bcostm 1:ce08f1d8140c 4 Before to use this example, ensure that you an hyperterminal installed on your
bcostm 1:ce08f1d8140c 5 computer. More info here: https://developer.mbed.org/handbook/Terminals
bcostm 1:ce08f1d8140c 6
bcostm 1:ce08f1d8140c 7 The default serial comm port uses the SERIAL_TX and SERIAL_RX pins (see their
bcostm 1:ce08f1d8140c 8 definition in the PinNames.h file).
bcostm 1:ce08f1d8140c 9
bcostm 1:ce08f1d8140c 10 The default serial configuration in this case is 9600 bauds, 8-bit data, no parity
bcostm 1:ce08f1d8140c 11
bcostm 1:ce08f1d8140c 12 If you want to change the baudrate for example, you have to redeclare the
bcostm 1:ce08f1d8140c 13 serial object in your code:
bcostm 1:ce08f1d8140c 14
bcostm 1:ce08f1d8140c 15 Serial pc(SERIAL_TX, SERIAL_RX);
bcostm 1:ce08f1d8140c 16
bcostm 1:ce08f1d8140c 17 Then, you can modify the baudrate and print like this:
bcostm 1:ce08f1d8140c 18
bcostm 1:ce08f1d8140c 19 pc.baud(115200);
bcostm 1:ce08f1d8140c 20 pc.printf("Hello World !\n");
bcostm 1:ce08f1d8140c 21 ------------------------------------------------------------------------------*/
bcostm 0:0ee4748f4c5c 22
bcostm 0:0ee4748f4c5c 23 DigitalOut led(LED1);
bcostm 0:0ee4748f4c5c 24
bcostm 0:0ee4748f4c5c 25 int main()
bcostm 0:0ee4748f4c5c 26 {
bcostm 0:0ee4748f4c5c 27 int i = 1;
bcostm 0:0ee4748f4c5c 28
bcostm 0:0ee4748f4c5c 29 printf("Hello World !\n");
bcostm 0:0ee4748f4c5c 30
bcostm 0:0ee4748f4c5c 31 while(1) {
bcostm 0:0ee4748f4c5c 32 wait(1); // 1 second
bcostm 0:0ee4748f4c5c 33 led = !led; // Toggle LED
bcostm 0:0ee4748f4c5c 34 printf("This program runs since %d seconds.\n", i++);
bcostm 0:0ee4748f4c5c 35 }
bcostm 0:0ee4748f4c5c 36 }