Demo using the user button and serial port on the Nucleo board, for Stage 1 Engineering at the University of York

Dependencies:   UoY-serial

main.cpp

Committer:
ajp109
Date:
2020-11-21
Revision:
3:e09e8c0d8dea
Parent:
2:bc854fc3d2a3
Child:
4:20d75a9afbbd

File content as of revision 3:e09e8c0d8dea:

#include "mbed.h"
#include "UoY-utils.h"

// Initialise the serial connection with the PC
serial_setup(USBTX, USBRX, 9600);

int main()
{
    // Initialise the digital pin USER_BUTTON (the blue button) as an input
    DigitalIn button(USER_BUTTON);

    // Loop forever...
    while (true) {
        // Is the button being pressed?
        if (button == true) {
            printf("Button is up\n");
        } else {
            printf("Button is down\n");
        }    
        // Wait for 500ms
        thread_sleep_for(500);
    }
}