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.
main.cpp@0:65dee900759a, 2018-11-15 (annotated)
- Committer:
- Wizo
- Date:
- Thu Nov 15 18:05:27 2018 +0000
- Revision:
- 0:65dee900759a
Timer
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Wizo | 0:65dee900759a | 1 | #include "mbed.h" |
| Wizo | 0:65dee900759a | 2 | Timer timer1; // define timer object |
| Wizo | 0:65dee900759a | 3 | DigitalOut output1(p5); // digital output |
| Wizo | 0:65dee900759a | 4 | void task1(void); // task function prototype |
| Wizo | 0:65dee900759a | 5 | //*** main code |
| Wizo | 0:65dee900759a | 6 | int main() |
| Wizo | 0:65dee900759a | 7 | { |
| Wizo | 0:65dee900759a | 8 | timer1.start(); // start timer counting |
| Wizo | 0:65dee900759a | 9 | while(1) { |
| Wizo | 0:65dee900759a | 10 | if (timer1.read_ms()>=200) { // read time in ms |
| Wizo | 0:65dee900759a | 11 | task1(); // call task function |
| Wizo | 0:65dee900759a | 12 | timer1.reset(); // reset timer |
| Wizo | 0:65dee900759a | 13 | } |
| Wizo | 0:65dee900759a | 14 | } |
| Wizo | 0:65dee900759a | 15 | } |
| Wizo | 0:65dee900759a | 16 | void task1(void) // task function |
| Wizo | 0:65dee900759a | 17 | { |
| Wizo | 0:65dee900759a | 18 | output1=!output1; // toggle output |
| Wizo | 0:65dee900759a | 19 | } |