hi
Dependencies: DebouncedInterrupt mbed
Fork of InterruptIn_HelloWorld by
Diff: main.cpp
- Revision:
- 1:da4614736799
- Parent:
- 0:7a20a6aa1f5e
--- a/main.cpp Fri Feb 15 15:13:19 2013 +0000 +++ b/main.cpp Thu Sep 29 22:19:13 2016 +0000 @@ -1,17 +1,67 @@ #include "mbed.h" - -InterruptIn button(p5); -DigitalOut led(LED1); -DigitalOut flash(LED4); - -void flip() { - led = !led; -} +#include "DebouncedInterrupt.h" + + DigitalOut columnoneout ( D5 ); // pin 3 on keypad + DigitalOut columntwoout ( D4 ); // pin 1 on keypad + DigitalOut columnthreeout ( D2 ); // pin 5 on keypad + +//InterruptIn button(USER_BUTTON); //set user blue button as interrupt +DebouncedInterrupt rowOne(D12); +DebouncedInterrupt rowTwo(D11); +DebouncedInterrupt rowThree(D7); +DebouncedInterrupt rowFour(D6); + +void InterrRowOne() { //this is a function (instructions) that will happen when interrupt happens + if ( columnoneout == 1){ + printf("3\n");} + if ( columntwoout == 1){ + printf("1\n");} + if ( columnthreeout == 1){ + printf("2\n");} } + +void InterrRowTwo() { //this is a function (instructions) that will happen when interrupt happens + if ( columnoneout == 1){ + printf("6\n");} + if ( columntwoout == 1){ + printf("4\n");} + if ( columnthreeout == 1){ + printf("5\n");} } + +void InterrRowThree() { //this is a function (instructions) that will happen when interrupt happens + if ( columnoneout == 1){ + printf("9\n");} + if ( columntwoout == 1){ + printf("7\n");} + if ( columnthreeout == 1){ + printf("8\n");} } + +void InterrRowFour() { //this is a function (instructions) that will happen when interrupt happens + if ( columnoneout == 1){ + printf("#\n");} + if ( columntwoout == 1){ + printf("*\n");} + if ( columnthreeout == 1){ + printf("0\n");} } int main() { - button.rise(&flip); // attach the address of the flip function to the rising edge + + // Will immediatly call function and ignore other interrupts until timeout + rowOne.attach(&InterrRowOne, IRQ_FALL, 100, false); + rowTwo.attach(&InterrRowTwo, IRQ_FALL, 100, false); + rowThree.attach(&InterrRowThree, IRQ_FALL, 100, false); + rowFour.attach(&InterrRowFour, IRQ_FALL, 100, false); + while(1) { // wait around, interrupts will interrupt this! - flash = !flash; - wait(0.25); - } -} \ No newline at end of file + + //alternate pulses + columnoneout = 1; + wait (0.01); + columnoneout = 0; + columntwoout = 1; + wait (0.01); + columntwoout = 0; + columnthreeout = 1; + wait (0.01); + columnthreeout = 0; + } + } \ No newline at end of file