Demo using the user button and serial port on the Nucleo board, for Stage 1 Engineering at the University of York
main.cpp
- Committer:
- ajp109
- Date:
- 2020-08-27
- Revision:
- 1:ee571cefc13b
- Parent:
- 0:fac2ffd6f143
- Child:
- 2:bc854fc3d2a3
File content as of revision 1:ee571cefc13b:
#include "mbed.h" int main() { // Initialise the digital pin USER_BUTTON (the blue button) as an input DigitalIn button(USER_BUTTON); // Initialise the serial connection with the PC Serial pc(USBTX, USBRX); // Loop forever... while (true) { // Is the button being pressed? if (button) { pc.printf("Button is up\n"); } else { pc.printf("Button is down\n"); } // Wait for 500ms thread_sleep_for(500); } }