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
main.cpp@2:8b678520a9fb, 2022-09-30 (annotated)
- Committer:
- mus3
- Date:
- Fri Sep 30 20:46:33 2022 +0000
- Revision:
- 2:8b678520a9fb
- Parent:
- 1:dcd96a8ef857
- Child:
- 3:708851531127
small changes
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbed_official | 0:5014bf742e9b | 1 | #include "mbed.h" |
| mbed_official | 0:5014bf742e9b | 2 | |
| mbed_official | 0:5014bf742e9b | 3 | Ticker flipper; |
| mbed_official | 0:5014bf742e9b | 4 | DigitalOut led1(LED1); |
| mbed_official | 0:5014bf742e9b | 5 | DigitalOut led2(LED2); |
| logostarr | 1:dcd96a8ef857 | 6 | DigitalOut led3(LED3); |
| logostarr | 1:dcd96a8ef857 | 7 | DigitalOut led4(LED4); |
| mus3 | 2:8b678520a9fb | 8 | int i = 0; |
| logostarr | 1:dcd96a8ef857 | 9 | |
| logostarr | 1:dcd96a8ef857 | 10 | void flip2() { |
| mbed_official | 0:5014bf742e9b | 11 | led2 = !led2; |
| mbed_official | 0:5014bf742e9b | 12 | } |
| logostarr | 1:dcd96a8ef857 | 13 | void flip1() { |
| logostarr | 1:dcd96a8ef857 | 14 | led1 = !led1; |
| logostarr | 1:dcd96a8ef857 | 15 | } |
| logostarr | 1:dcd96a8ef857 | 16 | void flip3() { |
| logostarr | 1:dcd96a8ef857 | 17 | led3 = !led3; |
| logostarr | 1:dcd96a8ef857 | 18 | } |
| logostarr | 1:dcd96a8ef857 | 19 | void flip4() { |
| logostarr | 1:dcd96a8ef857 | 20 | led4 = !led4; |
| logostarr | 1:dcd96a8ef857 | 21 | } |
| mbed_official | 0:5014bf742e9b | 22 | |
| mbed_official | 0:5014bf742e9b | 23 | int main() { |
| logostarr | 1:dcd96a8ef857 | 24 | flipper.attach(&flip2, 2 ); // the address of the function to be attached (flip) and the interval (2 seconds) |
| logostarr | 1:dcd96a8ef857 | 25 | flipper.attach(&flip1, 1); |
| logostarr | 1:dcd96a8ef857 | 26 | flipper.attach(&flip3, 4); |
| logostarr | 1:dcd96a8ef857 | 27 | flipper.attach(&flip4, 8); |
| mbed_official | 0:5014bf742e9b | 28 | // spin in a main loop. flipper will interrupt it to call flip |
| mbed_official | 0:5014bf742e9b | 29 | while(1) { |
| mus3 | 2:8b678520a9fb | 30 | i++; |
| logostarr | 1:dcd96a8ef857 | 31 | } |
| mbed_official | 0:5014bf742e9b | 32 | } |