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 A3_1_Single_Timer
main.cpp@1:3cadb8807520, 2021-10-07 (annotated)
- Committer:
- slicht_instructor
- Date:
- Thu Oct 07 12:04:46 2021 +0000
- Revision:
- 1:3cadb8807520
- Parent:
- 0:5597320f2dba
Base code for assignment 2.2, OCE360 2021
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
slicht_instructor | 1:3cadb8807520 | 1 | //Base code for modification for Assignment 2.2 |
slicht_instructor | 0:5597320f2dba | 2 | //Blinks LED2 every 200ms using a single Timer object. |
slicht_instructor | 0:5597320f2dba | 3 | //Created: S. Licht, 10/04/2020 |
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 |
slicht_instructor | 0:5597320f2dba | 8 | DigitalOut LEDOut2(LED2); |
slicht_instructor | 0:5597320f2dba | 9 | |
slicht_instructor | 0:5597320f2dba | 10 | int main() |
slicht_instructor | 0:5597320f2dba | 11 | { |
slicht_instructor | 0:5597320f2dba | 12 | timerLED2.start(); //start timer counting |
slicht_instructor | 0:5597320f2dba | 13 | |
slicht_instructor | 0:5597320f2dba | 14 | while(1) { |
slicht_instructor | 0:5597320f2dba | 15 | if (timerLED2.read_ms()>=200) { //check to see if time has been exceeded |
slicht_instructor | 0:5597320f2dba | 16 | LEDOut2 = !LEDOut2; |
slicht_instructor | 0:5597320f2dba | 17 | timerLED2.reset(); //reset the timer back to zero |
slicht_instructor | 0:5597320f2dba | 18 | } //if timer |
slicht_instructor | 0:5597320f2dba | 19 | |
slicht_instructor | 0:5597320f2dba | 20 | //if you had other code that you wanted to execute faster, |
slicht_instructor | 0:5597320f2dba | 21 | //you could put it here! |
slicht_instructor | 0:5597320f2dba | 22 | |
slicht_instructor | 0:5597320f2dba | 23 | } //while |
slicht_instructor | 0:5597320f2dba | 24 | } |