Example
main.cpp@2:0d2c7e88e277, 2017-12-15 (annotated)
- Committer:
- Frederick_H
- Date:
- Fri Dec 15 08:21:15 2017 +0000
- Revision:
- 2:0d2c7e88e277
- Parent:
- 0:57e0a19da71e
Example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:57e0a19da71e | 1 | #include "mbed.h" |
bcostm | 0:57e0a19da71e | 2 | |
bcostm | 0:57e0a19da71e | 3 | Ticker toggle_led_ticker; |
bcostm | 0:57e0a19da71e | 4 | |
bcostm | 0:57e0a19da71e | 5 | DigitalOut led1(LED1); |
bcostm | 0:57e0a19da71e | 6 | |
bcostm | 0:57e0a19da71e | 7 | void toggle_led() { |
bcostm | 0:57e0a19da71e | 8 | led1 = !led1; |
bcostm | 0:57e0a19da71e | 9 | } |
bcostm | 0:57e0a19da71e | 10 | |
bcostm | 0:57e0a19da71e | 11 | int main() { |
bcostm | 0:57e0a19da71e | 12 | // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms) |
Frederick_H | 2:0d2c7e88e277 | 13 | toggle_led_ticker.attach(&toggle_led, 1.5); |
bcostm | 0:57e0a19da71e | 14 | while (true) { |
bcostm | 0:57e0a19da71e | 15 | // Do other things... |
bcostm | 0:57e0a19da71e | 16 | } |
bcostm | 0:57e0a19da71e | 17 | } |