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@2:1692cf4dda7f, 2020-10-06 (annotated)
- Committer:
- markschwarzer
- Date:
- Tue Oct 06 14:44:54 2020 +0000
- Revision:
- 2:1692cf4dda7f
- Parent:
- 1:60db0821e5bc
- Child:
- 3:7952403aaae6
two timer objects and two different blinking rates added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
markschwarzer | 1:60db0821e5bc | 1 | |
slicht_instructor | 0:5597320f2dba | 2 | //Blinks LED2 every 200ms using a single Timer object. |
markschwarzer | 1:60db0821e5bc | 3 | |
slicht_instructor | 0:5597320f2dba | 4 | |
slicht_instructor | 0:5597320f2dba | 5 | #include "mbed.h" |
slicht_instructor | 0:5597320f2dba | 6 | |
slicht_instructor | 0:5597320f2dba | 7 | Timer timerLED2; //creat timer object |
markschwarzer | 2:1692cf4dda7f | 8 | Timer timerLED3; |
slicht_instructor | 0:5597320f2dba | 9 | DigitalOut LEDOut2(LED2); |
markschwarzer | 2:1692cf4dda7f | 10 | DigitalOut LEDOut3(LED3); |
slicht_instructor | 0:5597320f2dba | 11 | |
slicht_instructor | 0:5597320f2dba | 12 | int main() |
slicht_instructor | 0:5597320f2dba | 13 | { |
slicht_instructor | 0:5597320f2dba | 14 | timerLED2.start(); //start timer counting |
markschwarzer | 2:1692cf4dda7f | 15 | timerLED3.start(); |
markschwarzer | 2:1692cf4dda7f | 16 | |
slicht_instructor | 0:5597320f2dba | 17 | while(1) { |
slicht_instructor | 0:5597320f2dba | 18 | if (timerLED2.read_ms()>=200) { //check to see if time has been exceeded |
slicht_instructor | 0:5597320f2dba | 19 | LEDOut2 = !LEDOut2; |
slicht_instructor | 0:5597320f2dba | 20 | timerLED2.reset(); //reset the timer back to zero |
markschwarzer | 2:1692cf4dda7f | 21 | } |
markschwarzer | 2:1692cf4dda7f | 22 | if (timerLED3.read_ms()>=400) { |
markschwarzer | 2:1692cf4dda7f | 23 | LEDOut3= !LEDOut3; |
markschwarzer | 2:1692cf4dda7f | 24 | timerLED3.reset(); } |
markschwarzer | 2:1692cf4dda7f | 25 | }} |