Andy Pomfret
/
UoY-32C-lab1-exercise
Template project for University of York ELE00032C Lab 1
main.cpp@3:35d45c4dd5d2, 2021-01-11 (annotated)
- Committer:
- ajp109
- Date:
- Mon Jan 11 13:47:06 2021 +0000
- Revision:
- 3:35d45c4dd5d2
- Parent:
- 2:f63cdb6f8a44
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ajp109 | 0:fac2ffd6f143 | 1 | #include "mbed.h" |
ajp109 | 0:fac2ffd6f143 | 2 | |
ajp109 | 0:fac2ffd6f143 | 3 | int main() |
ajp109 | 0:fac2ffd6f143 | 4 | { |
ajp109 | 2:f63cdb6f8a44 | 5 | // Initialise the digital pins D2 and D3 as outputs |
ajp109 | 3:35d45c4dd5d2 | 6 | DigitalOut blue(D2); |
ajp109 | 2:f63cdb6f8a44 | 7 | DigitalOut red(D3); |
ajp109 | 2:f63cdb6f8a44 | 8 | |
ajp109 | 3:35d45c4dd5d2 | 9 | // Initialise the digital pin USER_BUTTON (the blue button) as an input |
ajp109 | 3:35d45c4dd5d2 | 10 | DigitalIn button(USER_BUTTON); |
ajp109 | 1:ee571cefc13b | 11 | |
ajp109 | 0:fac2ffd6f143 | 12 | // Loop forever... |
ajp109 | 0:fac2ffd6f143 | 13 | while (true) { |
ajp109 | 3:35d45c4dd5d2 | 14 | |
ajp109 | 3:35d45c4dd5d2 | 15 | // Flash the blue LED: on for 100ms, off for 300ms |
ajp109 | 3:35d45c4dd5d2 | 16 | // Your code modifications should be made here |
ajp109 | 3:35d45c4dd5d2 | 17 | blue = true; |
ajp109 | 3:35d45c4dd5d2 | 18 | thread_sleep_for(100); |
ajp109 | 3:35d45c4dd5d2 | 19 | blue = false; |
ajp109 | 3:35d45c4dd5d2 | 20 | thread_sleep_for(300); |
ajp109 | 3:35d45c4dd5d2 | 21 | |
ajp109 | 0:fac2ffd6f143 | 22 | } |
ajp109 | 0:fac2ffd6f143 | 23 | } |