Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 7:dd77d598e6cb
- Parent:
- 2:b60cb847489c
- Child:
- 8:5a2df0569c67
--- a/main.cpp Wed Sep 13 11:30:50 2017 +0000 +++ b/main.cpp Sat Dec 01 14:40:10 2018 +0000 @@ -1,12 +1,42 @@ #include "mbed.h" -DigitalOut myled(LED1); +/** Test + * Nucleo-F091 Getting started + */ + +Serial pc(SERIAL_TX, SERIAL_RX); +//9600, 8 data bits, no parity,1 stop bit,no flow control +DigitalOut onboardLed(LED1); +DigitalIn userButton(BUTTON1); -int main() { +int main() +{ + // Initial sequence + pc.printf("Hello World !\n\r"); + onboardLed=1; + wait(1.0f); //https://en.cppreference.com/w/cpp/language/floating_literal + onboardLed=!onboardLed; + wait(1.0f); + onboardLed=0; + pc.printf("Press any key on the keyboard to start the program\n\r"); + pc.putc(pc.getc()); //echo keyboard input, blocking wait + pc.printf(" was pressed\n\r"); + for (int32_t i=0;i<=10;i++){ + pc.printf("***\n\r"); //Generate some new lines + } + + + // Endless loop + int32_t i=0; while(1) { - myled = 1; // LED is ON - wait(0.2); // 200 ms - myled = 0; // LED is OFF - wait(1.0); // 1 sec + onboardLed.write(1); //switch on LED + wait_ms(200); + onboardLed.write(0); //switch off + wait_ms(700); + pc.printf("This program runs since %d (0x%X) seconds.\n\r", i,i); + if (userButton==0) { + pc.printf("Userbutton pressed\n\r"); + } + i++; //increase loop counter } }