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.
Dependencies: mbed
main.cpp@0:9a2d6e5f53d0, 2018-09-25 (annotated)
- Committer:
- matt495
- Date:
- Tue Sep 25 16:01:36 2018 +0000
- Revision:
- 0:9a2d6e5f53d0
ME21001 exercise 4
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| matt495 | 0:9a2d6e5f53d0 | 1 | /**************************************************************** |
| matt495 | 0:9a2d6e5f53d0 | 2 | / Simple program to show basic program structure |
| matt495 | 0:9a2d6e5f53d0 | 3 | / |
| matt495 | 0:9a2d6e5f53d0 | 4 | / The program flashes onboard LED #1, #2 and #3 on/off in sequence for 1 second and continues this indefinitely. |
| matt495 | 0:9a2d6e5f53d0 | 5 | *************************************************************/ |
| matt495 | 0:9a2d6e5f53d0 | 6 | |
| matt495 | 0:9a2d6e5f53d0 | 7 | #include "mbed.h" |
| matt495 | 0:9a2d6e5f53d0 | 8 | |
| matt495 | 0:9a2d6e5f53d0 | 9 | DigitalOut myled(p23); // use onboard LED #1 (red) |
| matt495 | 0:9a2d6e5f53d0 | 10 | DigitalOut myled2(p25); // use onboard LED #2 (green) |
| matt495 | 0:9a2d6e5f53d0 | 11 | DigitalOut myled3(p24); // use onboard LED #3 (yellow) |
| matt495 | 0:9a2d6e5f53d0 | 12 | |
| matt495 | 0:9a2d6e5f53d0 | 13 | int main() { |
| matt495 | 0:9a2d6e5f53d0 | 14 | |
| matt495 | 0:9a2d6e5f53d0 | 15 | while(1) { // repeat indefinitely |
| matt495 | 0:9a2d6e5f53d0 | 16 | myled = 1; // turn on LED #1 |
| matt495 | 0:9a2d6e5f53d0 | 17 | myled2 = 1; // turn on LED #2 |
| matt495 | 0:9a2d6e5f53d0 | 18 | myled3 = 1; // turn on LED #3 |
| matt495 | 0:9a2d6e5f53d0 | 19 | wait(1); // wait 1s |
| matt495 | 0:9a2d6e5f53d0 | 20 | myled = 0; // turn off LED #1 |
| matt495 | 0:9a2d6e5f53d0 | 21 | myled2 = 0; // turn off LED #2 |
| matt495 | 0:9a2d6e5f53d0 | 22 | myled3 = 0; // turn off LED #3 |
| matt495 | 0:9a2d6e5f53d0 | 23 | wait(1); // wait 1s |
| matt495 | 0:9a2d6e5f53d0 | 24 | } |
| matt495 | 0:9a2d6e5f53d0 | 25 | } |