![](/media/cache/group/Logo-slogen.png.50x50_q85.png)
Example using single button touch sensor
Dependencies: mbed
Fork of Seeed_Grove_Slider_Potentiometer_Example by
main.cpp@2:9b9cc4e82355, 2014-08-16 (annotated)
- Committer:
- sam_grove
- Date:
- Sat Aug 16 01:14:43 2014 +0000
- Revision:
- 2:9b9cc4e82355
- Parent:
- 1:401629079a98
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 0:46e460c85e27 | 1 | |
sam_grove | 0:46e460c85e27 | 2 | #include "mbed.h" |
sam_grove | 0:46e460c85e27 | 3 | |
sam_grove | 2:9b9cc4e82355 | 4 | DigitalIn button(D2); |
sam_grove | 0:46e460c85e27 | 5 | |
sam_grove | 0:46e460c85e27 | 6 | int main (void) |
sam_grove | 0:46e460c85e27 | 7 | { |
sam_grove | 2:9b9cc4e82355 | 8 | int cnt = 0; |
sam_grove | 2:9b9cc4e82355 | 9 | |
sam_grove | 0:46e460c85e27 | 10 | while(1) { |
sam_grove | 2:9b9cc4e82355 | 11 | if (button) { |
sam_grove | 2:9b9cc4e82355 | 12 | cnt++; |
sam_grove | 2:9b9cc4e82355 | 13 | printf("Touch detected %d\n", cnt); |
sam_grove | 2:9b9cc4e82355 | 14 | while(button); |
sam_grove | 2:9b9cc4e82355 | 15 | } |
sam_grove | 0:46e460c85e27 | 16 | } |
sam_grove | 0:46e460c85e27 | 17 | } |