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.
main.cpp
- Committer:
- JuergenSchuele
- Date:
- 2018-12-01
- Revision:
- 7:dd77d598e6cb
- Parent:
- 2:b60cb847489c
- Child:
- 8:0cfa131f854c
File content as of revision 7:dd77d598e6cb:
#include "mbed.h"
/** 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()
{
    // 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) {
        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        
    }
}