
Template project for University of York ELE00032C Lab 1
Revision 1:ee571cefc13b, committed 2020-08-27
- Comitter:
- ajp109
- Date:
- Thu Aug 27 10:14:27 2020 +0000
- Parent:
- 0:fac2ffd6f143
- Child:
- 2:f63cdb6f8a44
- Commit message:
- Initial commit
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Aug 25 11:00:34 2020 +0000 +++ b/main.cpp Thu Aug 27 10:14:27 2020 +0000 @@ -3,18 +3,21 @@ int main() { - // Initialise the digital pin LED1 as an output - DigitalOut led(LED1); + // 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) { - // Switch the LED on - led = true; - // Wait for 200ms - thread_sleep_for(200); - // Switch the LED off - led = false; - // Wait for 300ms - thread_sleep_for(300); + // 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); } }