Demo using the user button and serial port on the Nucleo board, for Stage 1 Engineering at the University of York
main.cpp@0:fac2ffd6f143, 2020-08-25 (annotated)
- Committer:
- ajp109
- Date:
- Tue Aug 25 11:00:34 2020 +0000
- Revision:
- 0:fac2ffd6f143
- Child:
- 1:ee571cefc13b
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ajp109 | 0:fac2ffd6f143 | 1 | |
ajp109 | 0:fac2ffd6f143 | 2 | #include "mbed.h" |
ajp109 | 0:fac2ffd6f143 | 3 | |
ajp109 | 0:fac2ffd6f143 | 4 | int main() |
ajp109 | 0:fac2ffd6f143 | 5 | { |
ajp109 | 0:fac2ffd6f143 | 6 | // Initialise the digital pin LED1 as an output |
ajp109 | 0:fac2ffd6f143 | 7 | DigitalOut led(LED1); |
ajp109 | 0:fac2ffd6f143 | 8 | |
ajp109 | 0:fac2ffd6f143 | 9 | // Loop forever... |
ajp109 | 0:fac2ffd6f143 | 10 | while (true) { |
ajp109 | 0:fac2ffd6f143 | 11 | // Switch the LED on |
ajp109 | 0:fac2ffd6f143 | 12 | led = true; |
ajp109 | 0:fac2ffd6f143 | 13 | // Wait for 200ms |
ajp109 | 0:fac2ffd6f143 | 14 | thread_sleep_for(200); |
ajp109 | 0:fac2ffd6f143 | 15 | // Switch the LED off |
ajp109 | 0:fac2ffd6f143 | 16 | led = false; |
ajp109 | 0:fac2ffd6f143 | 17 | // Wait for 300ms |
ajp109 | 0:fac2ffd6f143 | 18 | thread_sleep_for(300); |
ajp109 | 0:fac2ffd6f143 | 19 | } |
ajp109 | 0:fac2ffd6f143 | 20 | } |