![](/media/cache/profiles/3091d86c09a002e144f4ec506eada3d7.50x50_q85.jpg)
Oddness with multiple \'InterruptIn\'s
Diff: main.cpp
- Revision:
- 0:ba602786a4c1
- Child:
- 1:0228f6b60488
diff -r 000000000000 -r ba602786a4c1 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 30 15:53:03 2011 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); + +InterruptIn button1(p12); +InterruptIn button2(p11); +InterruptIn button3(p10); + +Timeout button1_debounce; +Timeout button2_debounce; +Timeout button3_debounce; + +void button1_pressed() {pc.printf("Button 1");} +void button2_pressed() {pc.printf("Button 2");} +void button3_pressed() {pc.printf("Button 3");} + +void button1_press() {button1_debounce.attach(button1_pressed, 0.3);} +void button2_press() {button2_debounce.attach(button2_pressed, 0.3);} +void button3_press() {button3_debounce.attach(button3_pressed, 0.3);} + + +int main() +{ + // Set up buttons + button1.mode(PullDown); + button1.rise(&button1_press); + + button2.mode(PullDown); + button2.rise(&button2_press); + + button3.mode(PullDown); + button3.rise(&button3_press); + + while (1); +} \ No newline at end of file