Nicholas Outram
/
Task121
updated for mbed-os 5.5
main.cpp@3:82771b5493b3, 2017-07-13 (annotated)
- Committer:
- noutram
- Date:
- Thu Jul 13 10:24:48 2017 +0000
- Revision:
- 3:82771b5493b3
- Parent:
- 1:a3b418536134
Task121
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
noutram | 0:c742e33896a9 | 1 | //This is known as a “header file” |
noutram | 0:c742e33896a9 | 2 | //In short, this copies and pastes the text file |
noutram | 0:c742e33896a9 | 3 | //mbed.h into this code |
noutram | 0:c742e33896a9 | 4 | #include "mbed.h" |
noutram | 0:c742e33896a9 | 5 | |
noutram | 0:c742e33896a9 | 6 | //Create a DigitalOut “object” called myled |
noutram | 0:c742e33896a9 | 7 | //Pass constant D7 as a “parameter” |
noutram | 0:c742e33896a9 | 8 | DigitalOut myled(D7); |
noutram | 0:c742e33896a9 | 9 | |
noutram | 0:c742e33896a9 | 10 | //The main function - all executable C / C++ |
noutram | 0:c742e33896a9 | 11 | //applications have a main function. This is |
noutram | 0:c742e33896a9 | 12 | //out entry point in the software |
noutram | 0:c742e33896a9 | 13 | int main() { |
noutram | 0:c742e33896a9 | 14 | |
noutram | 0:c742e33896a9 | 15 | // ALL the code is contained in a |
noutram | 0:c742e33896a9 | 16 | // “while loop” |
noutram | 0:c742e33896a9 | 17 | while(1) |
noutram | 0:c742e33896a9 | 18 | { |
noutram | 0:c742e33896a9 | 19 | //The code between the { curly braces } |
noutram | 0:c742e33896a9 | 20 | //is the code that is repeated |
noutram | 0:c742e33896a9 | 21 | myled = 1; // External LED is ON |
noutram | 0:c742e33896a9 | 22 | wait(1.0); // 1 second |
noutram | 0:c742e33896a9 | 23 | myled = 0; // LED is OFF |
noutram | 0:c742e33896a9 | 24 | wait(1.0); // External 1 second |
noutram | 0:c742e33896a9 | 25 | } |
noutram | 1:a3b418536134 | 26 | } |
noutram | 1:a3b418536134 | 27 | |
noutram | 1:a3b418536134 | 28 | //updated for mbed os 5.4 |
noutram | 1:a3b418536134 | 29 |