Takahiro Abe
/
Pushbutton_BadBounce_Interrupt
test
Fork of Pushbutton_BadBounce_Interrupt by
main.cpp@2:4995292ee59f, 2018-09-14 (annotated)
- Committer:
- takahiroabe
- Date:
- Fri Sep 14 01:21:05 2018 +0000
- Revision:
- 2:4995292ee59f
- Parent:
- 1:6582c095e8d1
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
4180_1 | 0:7db73d1dc65f | 1 | #include "mbed.h" |
4180_1 | 0:7db73d1dc65f | 2 | |
4180_1 | 0:7db73d1dc65f | 3 | DigitalOut myled(LED1); |
takahiroabe | 2:4995292ee59f | 4 | InterruptIn pb(p8,PullNone); |
takahiroabe | 2:4995292ee59f | 5 | Serial pc(USBTX, USBRX); |
4180_1 | 0:7db73d1dc65f | 6 | |
takahiroabe | 2:4995292ee59f | 7 | |
4180_1 | 0:7db73d1dc65f | 8 | |
4180_1 | 0:7db73d1dc65f | 9 | // Global count variable |
4180_1 | 0:7db73d1dc65f | 10 | int volatile count=0; |
4180_1 | 0:7db73d1dc65f | 11 | |
4180_1 | 0:7db73d1dc65f | 12 | // pb Interrupt routine - is interrupt activated by a falling edge of pb input |
4180_1 | 0:7db73d1dc65f | 13 | void pb_hit_interrupt (void) { |
4180_1 | 0:7db73d1dc65f | 14 | count++; |
4180_1 | 0:7db73d1dc65f | 15 | } |
4180_1 | 0:7db73d1dc65f | 16 | |
4180_1 | 0:7db73d1dc65f | 17 | int main() { |
takahiroabe | 2:4995292ee59f | 18 | wait(0.01); |
takahiroabe | 2:4995292ee59f | 19 | pc.printf("Hello Deboucing \r\n"); |
takahiroabe | 2:4995292ee59f | 20 | |
4180_1 | 0:7db73d1dc65f | 21 | pb.fall(&pb_hit_interrupt); |
takahiroabe | 2:4995292ee59f | 22 | |
4180_1 | 0:7db73d1dc65f | 23 | while (1) { |
4180_1 | 0:7db73d1dc65f | 24 | myled = !myled; |
takahiroabe | 2:4995292ee59f | 25 | wait(0.5); |
4180_1 | 0:7db73d1dc65f | 26 | } |
4180_1 | 0:7db73d1dc65f | 27 | } |