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@2:de9d94dc0454, 2020-10-06 (annotated)
- Committer:
- markschwarzer
- Date:
- Tue Oct 06 14:53:06 2020 +0000
- Revision:
- 2:de9d94dc0454
- Parent:
- 1:76d11e984b8d
- Child:
- 3:d90d04dce9f2
Initial imported code
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| markschwarzer | 2:de9d94dc0454 | 1 | |
| slicht_instructor | 1:76d11e984b8d | 2 | #include "mbed.h" |
| slicht_instructor | 1:76d11e984b8d | 3 | Ticker tickerLED2; //creat ticker object |
| slicht_instructor | 1:76d11e984b8d | 4 | DigitalOut LEDOut2(LED2); |
| slicht_instructor | 0:5597320f2dba | 5 | |
| slicht_instructor | 1:76d11e984b8d | 6 | void changeLED2() //the function that will be called by the ticker object. |
| slicht_instructor | 1:76d11e984b8d | 7 | { |
| slicht_instructor | 1:76d11e984b8d | 8 | LEDOut2 = !LEDOut2; |
| slicht_instructor | 1:76d11e984b8d | 9 | } |
| slicht_instructor | 0:5597320f2dba | 10 | |
| slicht_instructor | 0:5597320f2dba | 11 | int main() |
| slicht_instructor | 0:5597320f2dba | 12 | { |
| slicht_instructor | 1:76d11e984b8d | 13 | tickerLED2.attach(&changeLED2,0.2); //the address of the function to call |
| slicht_instructor | 1:76d11e984b8d | 14 | //and the interval in seconds between |
| slicht_instructor | 1:76d11e984b8d | 15 | //calls to that function |
| slicht_instructor | 0:5597320f2dba | 16 | |
| slicht_instructor | 0:5597320f2dba | 17 | while(1) { |
| slicht_instructor | 1:76d11e984b8d | 18 | wait(0.1); |
| slicht_instructor | 1:76d11e984b8d | 19 | wait(0.1); |
| slicht_instructor | 1:76d11e984b8d | 20 | wait(0.1); |
| slicht_instructor | 1:76d11e984b8d | 21 | wait(0.1); |
| slicht_instructor | 1:76d11e984b8d | 22 | wait(0.1); |
| slicht_instructor | 1:76d11e984b8d | 23 | //the main loop is spinning every 500ms, but the LED needs to go faster! |
| slicht_instructor | 0:5597320f2dba | 24 | } //while |
| slicht_instructor | 0:5597320f2dba | 25 | } |