basic function test (led and printf)

Dependencies:   mbed

Fork of mbed_blinky by Mbed

Files at this revision

API Documentation at this revision

Comitter:
Bongjun
Date:
Wed Jul 18 06:25:24 2018 +0000
Parent:
20:7c9e1ce926ec
Commit message:
add "printf" function and set the serial speed

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 7c9e1ce926ec -r 927c132ae8ca main.cpp
--- a/main.cpp	Mon Mar 05 00:46:55 2018 +0000
+++ b/main.cpp	Wed Jul 18 06:25:24 2018 +0000
@@ -1,12 +1,14 @@
 #include "mbed.h"
-
-DigitalOut myled(LED1);
+// define the Serial object
+Serial pc(USBTX, USBRX);
+DigitalOut led1(LED1);
 
 int main() {
-    while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+    pc.baud(115200);
+    while (true) {
+        led1 = !led1;
+        // Print something over the serial connection
+        pc.printf("Blink! LED is now %d\r\n", led1.read());
+        wait(0.5);
     }
 }
diff -r 7c9e1ce926ec -r 927c132ae8ca mbed.bld
--- a/mbed.bld	Mon Mar 05 00:46:55 2018 +0000
+++ b/mbed.bld	Wed Jul 18 06:25:24 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/aa5281ff4a02
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/a7c7b631e539
\ No newline at end of file