Exercise 2c

Dependencies:   MODSERIAL mbed

Fork of Minor_test_serial by First Last

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "MODSERIAL.h"
00003 
00004 DigitalOut myled(LED_GREEN);
00005 MODSERIAL pc(USBTX, USBRX);
00006 
00007 int main()
00008 {
00009     int i = 0;
00010     char c;
00011     pc.baud(115200);
00012     pc.printf("Hello World!\r\n");
00013     
00014     while (true) {
00015         wait(0.5f); // wait a small period of time
00016         c = pc.getc();
00017         pc.printf("%c \r\n", c); // print the value of variable i
00018         i++; // increment the variable
00019         myled = !myled; // toggle a led
00020     }
00021 }