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:c1a2bfdd2087, 2018-09-25 (annotated)
- Committer:
- matt495
- Date:
- Tue Sep 25 16:00:40 2018 +0000
- Revision:
- 0:c1a2bfdd2087
ME21001 exercise 2;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| matt495 | 0:c1a2bfdd2087 | 1 | /**************************************************************** |
| matt495 | 0:c1a2bfdd2087 | 2 | / Simple program to show basic program structure |
| matt495 | 0:c1a2bfdd2087 | 3 | / |
| matt495 | 0:c1a2bfdd2087 | 4 | / The program flashes onboard LED #1 on/off 5 times, one second on and one second off. It then waits 5s before starting again. |
| matt495 | 0:c1a2bfdd2087 | 5 | /***************************************************************/ |
| matt495 | 0:c1a2bfdd2087 | 6 | |
| matt495 | 0:c1a2bfdd2087 | 7 | #include "mbed.h" |
| matt495 | 0:c1a2bfdd2087 | 8 | |
| matt495 | 0:c1a2bfdd2087 | 9 | DigitalOut myled(LED1); // use onboard LED #1 |
| matt495 | 0:c1a2bfdd2087 | 10 | |
| matt495 | 0:c1a2bfdd2087 | 11 | int main() { |
| matt495 | 0:c1a2bfdd2087 | 12 | |
| matt495 | 0:c1a2bfdd2087 | 13 | while(1) { // repeat indefinitely |
| matt495 | 0:c1a2bfdd2087 | 14 | for(int i=0; i<5; i++) { // set number of loops to 5 |
| matt495 | 0:c1a2bfdd2087 | 15 | myled = 1; // turn on LED #1 |
| matt495 | 0:c1a2bfdd2087 | 16 | wait(1.0); // wait 1s |
| matt495 | 0:c1a2bfdd2087 | 17 | myled = 0; // turn off LED #1 |
| matt495 | 0:c1a2bfdd2087 | 18 | wait(1.0); // wait 1s |
| matt495 | 0:c1a2bfdd2087 | 19 | } |
| matt495 | 0:c1a2bfdd2087 | 20 | wait (5.0); // wait 5s |
| matt495 | 0:c1a2bfdd2087 | 21 | } |
| matt495 | 0:c1a2bfdd2087 | 22 | } |