Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Task121 by
main.cpp@12:991c54e21f5f, 2020-07-16 (annotated)
- Committer:
- noutram
- Date:
- Thu Jul 16 10:10:13 2020 +0100
- Revision:
- 12:991c54e21f5f
- Parent:
- 11:d7337ffe7f85
stuff
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| noutram | 6:6aeae28837c4 | 1 | // Updated 2019 for Mbed-os 5.1X |
| noutram | 6:6aeae28837c4 | 2 | |
| noutram | 0:c742e33896a9 | 3 | //This is known as a “header file” |
| noutram | 0:c742e33896a9 | 4 | //In short, this copies and pastes the text file |
| noutram | 0:c742e33896a9 | 5 | //mbed.h into this code |
| noutram | 0:c742e33896a9 | 6 | #include "mbed.h" |
| noutram | 0:c742e33896a9 | 7 | |
| noutram | 0:c742e33896a9 | 8 | //Create a DigitalOut “object” called myled |
| noutram | 11:d7337ffe7f85 | 9 | //Pass constant LED1 as a “parameter” |
| noutram | 11:d7337ffe7f85 | 10 | DigitalOut myled(LED1); |
| noutram | 0:c742e33896a9 | 11 | |
| noutram | 0:c742e33896a9 | 12 | //The main function - all executable C / C++ |
| noutram | 0:c742e33896a9 | 13 | //applications have a main function. This is |
| noutram | 0:c742e33896a9 | 14 | //out entry point in the software |
| noutram | 0:c742e33896a9 | 15 | int main() { |
| noutram | 12:991c54e21f5f | 16 | //Write a welcome message to the terminal |
| noutram | 12:991c54e21f5f | 17 | puts("Welcome to the University of Plymouth"); |
| noutram | 0:c742e33896a9 | 18 | |
| noutram | 12:991c54e21f5f | 19 | // ALL the repearing code is contained in a |
| noutram | 12:991c54e21f5f | 20 | // “while loop” |
| noutram | 0:c742e33896a9 | 21 | while(1) |
| noutram | 0:c742e33896a9 | 22 | { |
| noutram | 0:c742e33896a9 | 23 | //The code between the { curly braces } |
| noutram | 0:c742e33896a9 | 24 | //is the code that is repeated |
| noutram | 0:c742e33896a9 | 25 | myled = 1; // External LED is ON |
| noutram | 9:5ac40ff61514 | 26 | wait_us(1000000); // 1 second |
| noutram | 0:c742e33896a9 | 27 | myled = 0; // LED is OFF |
| noutram | 9:5ac40ff61514 | 28 | wait_us(1000000); // External 1 second |
| noutram | 0:c742e33896a9 | 29 | } |
| noutram | 1:a3b418536134 | 30 | } |
| noutram | 1:a3b418536134 | 31 | |
| noutram | 1:a3b418536134 | 32 | |
| noutram | 7:bc61039bc0dc | 33 |
