![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Demo using the user button and serial port on the Nucleo board, for Stage 1 Engineering at the University of York
Diff: main.cpp
- Revision:
- 3:e09e8c0d8dea
- Parent:
- 2:bc854fc3d2a3
- Child:
- 4:20d75a9afbbd
diff -r bc854fc3d2a3 -r e09e8c0d8dea main.cpp --- a/main.cpp Mon Sep 28 16:03:05 2020 +0000 +++ b/main.cpp Sat Nov 21 13:44:40 2020 +0000 @@ -1,20 +1,21 @@ #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); - - // Initialise the serial connection with the PC - Serial pc(USBTX, USBRX); // Loop forever... while (true) { // Is the button being pressed? if (button == true) { - pc.printf("Button is up\n"); + printf("Button is up\n"); } else { - pc.printf("Button is down\n"); + printf("Button is down\n"); } // Wait for 500ms thread_sleep_for(500);