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@7:c56b212b084e, 2016-11-10 (annotated)
- Committer:
- imihalj
- Date:
- Thu Nov 10 18:02:06 2016 +0000
- Revision:
- 7:c56b212b084e
- Parent:
- 6:ca9ae5ce232d
- Child:
- 8:e81d54d7ced6
vjezba6_3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
imihalj | 6:ca9ae5ce232d | 1 | #include "mbed.h" |
imihalj | 7:c56b212b084e | 2 | Ticker flipper1; |
imihalj | 7:c56b212b084e | 3 | Ticker flipper2; |
imihalj | 7:c56b212b084e | 4 | DigitalOut led1(p5); |
imihalj | 7:c56b212b084e | 5 | DigitalOut led2(p6); |
imihalj | 7:c56b212b084e | 6 | void flip1() // flip 1 function |
imihalj | 7:c56b212b084e | 7 | { |
imihalj | 7:c56b212b084e | 8 | led1 = !led1; |
imihalj | 7:c56b212b084e | 9 | } |
imihalj | 7:c56b212b084e | 10 | void flip2() // flip 2 function |
imihalj | 7:c56b212b084e | 11 | { |
imihalj | 7:c56b212b084e | 12 | led2 = !led2; |
imihalj | 7:c56b212b084e | 13 | } |
imihalj | 0:c32036656bb4 | 14 | int main() |
imihalj | 0:c32036656bb4 | 15 | { |
imihalj | 7:c56b212b084e | 16 | led1 = 0; |
imihalj | 7:c56b212b084e | 17 | led2 = 0; |
imihalj | 7:c56b212b084e | 18 | flipper1.attach(&flip1, 0.2); // the address of the |
imihalj | 7:c56b212b084e | 19 | // function to be attached |
imihalj | 7:c56b212b084e | 20 | // and the interval (sec) |
imihalj | 7:c56b212b084e | 21 | flipper2.attach(&flip2, 1.0); |
imihalj | 7:c56b212b084e | 22 | // spin in a main loop |
imihalj | 7:c56b212b084e | 23 | // flipper will interrupt it to call flip |
imihalj | 4:986fa54b04b5 | 24 | while(1) { |
imihalj | 7:c56b212b084e | 25 | wait(0.2); |
imihalj | 4:986fa54b04b5 | 26 | } |
imihalj | 5:94aa173f182c | 27 | } |
imihalj | 0:c32036656bb4 | 28 | } |