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
HelloWorld.cpp@1:3a83283bcc1c, 2014-06-06 (annotated)
- Committer:
- ethanharstad
- Date:
- Fri Jun 06 19:16:10 2014 +0000
- Revision:
- 1:3a83283bcc1c
- Parent:
- main.cpp@0:3619ce83ea6c
Rename file
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ethanharstad | 0:3619ce83ea6c | 1 | #include "mbed.h" |
| ethanharstad | 0:3619ce83ea6c | 2 | |
| ethanharstad | 0:3619ce83ea6c | 3 | unsigned int counter = 0; // Keep count of lifetime |
| ethanharstad | 0:3619ce83ea6c | 4 | Serial pc(USBTX, USBRX); // Talk to the computer |
| ethanharstad | 0:3619ce83ea6c | 5 | |
| ethanharstad | 0:3619ce83ea6c | 6 | void count() { |
| ethanharstad | 0:3619ce83ea6c | 7 | // Announce lifetime |
| ethanharstad | 0:3619ce83ea6c | 8 | pc.printf("I have been alive for %i seconds.\n", counter); |
| ethanharstad | 0:3619ce83ea6c | 9 | counter++; // Count up by 1 |
| ethanharstad | 0:3619ce83ea6c | 10 | } |
| ethanharstad | 0:3619ce83ea6c | 11 | |
| ethanharstad | 0:3619ce83ea6c | 12 | int main() { |
| ethanharstad | 0:3619ce83ea6c | 13 | pc.printf("Hello world!\n"); // Say hello |
| ethanharstad | 0:3619ce83ea6c | 14 | while(true) { // Main loop |
| ethanharstad | 0:3619ce83ea6c | 15 | count(); // Call our function |
| ethanharstad | 0:3619ce83ea6c | 16 | wait(1); // Wait for 1 second |
| ethanharstad | 0:3619ce83ea6c | 17 | } // Repeat |
| ethanharstad | 0:3619ce83ea6c | 18 | } |