Secretariat STIoTChallenge
/
Module1
Hello World
Revision 7:eb08743a8674, committed 2019-08-02
- Comitter:
- stiotchallenge
- Date:
- Fri Aug 02 04:47:04 2019 +0000
- Parent:
- 6:4e6ec83d3c83
- Commit message:
- Module 1: Hello World
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4e6ec83d3c83 -r eb08743a8674 main.cpp --- a/main.cpp Wed Sep 13 11:30:50 2017 +0000 +++ b/main.cpp Fri Aug 02 04:47:04 2019 +0000 @@ -1,12 +1,20 @@ #include "mbed.h" +//------------------------------------ +// Hyperterminal configuration +// 9600 bauds, 8-bit data, no parity +//------------------------------------ +DigitalIn mybutton(USER_BUTTON); DigitalOut myled(LED1); +Serial pc(SERIAL_TX, SERIAL_RX); int main() { - while(1) { - myled = 1; // LED is ON + int i = 1; + pc.printf("Hello World !\n"); + if (mybutton == 0) { // Button is pressed + myled = !myled; // Toggle the LED state wait(0.2); // 200 ms - myled = 0; // LED is OFF - wait(1.0); // 1 sec - } + } + pc.printf("This program runs since %d seconds.\n", i++); + wait(1); }