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.
Fork of InterruptIn_HelloWorld by
main.cpp@0:7a20a6aa1f5e, 2013-02-15 (annotated)
- Committer:
- mbed_official
- Date:
- Fri Feb 15 15:13:19 2013 +0000
- Revision:
- 0:7a20a6aa1f5e
- Child:
- 1:6c7f14195903
Hello World for InteruptIn
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:7a20a6aa1f5e | 1 | #include "mbed.h" |
mbed_official | 0:7a20a6aa1f5e | 2 | |
mbed_official | 0:7a20a6aa1f5e | 3 | InterruptIn button(p5); |
mbed_official | 0:7a20a6aa1f5e | 4 | DigitalOut led(LED1); |
mbed_official | 0:7a20a6aa1f5e | 5 | DigitalOut flash(LED4); |
mbed_official | 0:7a20a6aa1f5e | 6 | |
mbed_official | 0:7a20a6aa1f5e | 7 | void flip() { |
mbed_official | 0:7a20a6aa1f5e | 8 | led = !led; |
mbed_official | 0:7a20a6aa1f5e | 9 | } |
mbed_official | 0:7a20a6aa1f5e | 10 | |
mbed_official | 0:7a20a6aa1f5e | 11 | int main() { |
mbed_official | 0:7a20a6aa1f5e | 12 | button.rise(&flip); // attach the address of the flip function to the rising edge |
mbed_official | 0:7a20a6aa1f5e | 13 | while(1) { // wait around, interrupts will interrupt this! |
mbed_official | 0:7a20a6aa1f5e | 14 | flash = !flash; |
mbed_official | 0:7a20a6aa1f5e | 15 | wait(0.25); |
mbed_official | 0:7a20a6aa1f5e | 16 | } |
mbed_official | 0:7a20a6aa1f5e | 17 | } |