Takahiro Abe
/
Pushbutton_BadBounce_Interrupt
test
Fork of Pushbutton_BadBounce_Interrupt by
Revision 2:4995292ee59f, committed 2018-09-14
- Comitter:
- takahiroabe
- Date:
- Fri Sep 14 01:21:05 2018 +0000
- Parent:
- 1:6582c095e8d1
- Commit message:
- test
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 06 00:55:26 2011 +0000 +++ b/main.cpp Fri Sep 14 01:21:05 2018 +0000 @@ -1,15 +1,10 @@ #include "mbed.h" DigitalOut myled(LED1); -DigitalOut myled2(LED2); -DigitalOut myled3(LED3); -DigitalOut myled4(LED4); +InterruptIn pb(p8,PullNone); +Serial pc(USBTX, USBRX); -InterruptIn pb(p8); -// SPST Pushbutton count demo using interrupts -// no external PullUp resistor needed -// Pushbutton from P8 to GND. -// A pb hit generates an interrupt and activates the interrupt routine + // Global count variable int volatile count=0; @@ -17,22 +12,16 @@ // pb Interrupt routine - is interrupt activated by a falling edge of pb input void pb_hit_interrupt (void) { count++; - myled4 = count & 0x01; - myled3 = (count & 0x02)>>1; - myled2 = (count & 0x04)>>2; } int main() { - // Use internal pullup for pushbutton - pb.mode(PullUp); - // Delay for initial pullup to take effect - wait(.01); - // Attach the address of the interrupt handler routine for pushbutton + wait(0.01); + pc.printf("Hello Deboucing \r\n"); + pb.fall(&pb_hit_interrupt); - // Blink myled in main routine forever while responding to pb changes - // via interrupts that activate pb_hit_interrupt routine + while (1) { myled = !myled; - wait(.5); + wait(0.5); } } \ No newline at end of file
--- a/mbed.bld Thu Oct 06 00:55:26 2011 +0000 +++ b/mbed.bld Fri Sep 14 01:21:05 2018 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912 +http://mbed.org/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file