Button Press on Vibro Model
Dependencies: mbed
main.cpp@0:7b26ada49c8f, 2014-11-05 (annotated)
- Committer:
- mfillinois
- Date:
- Wed Nov 05 00:44:17 2014 +0000
- Revision:
- 0:7b26ada49c8f
FirstTry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mfillinois | 0:7b26ada49c8f | 1 | #include "mbed.h" |
mfillinois | 0:7b26ada49c8f | 2 | |
mfillinois | 0:7b26ada49c8f | 3 | DigitalOut ledB(LED1); |
mfillinois | 0:7b26ada49c8f | 4 | InterruptIn button1(p15); |
mfillinois | 0:7b26ada49c8f | 5 | |
mfillinois | 0:7b26ada49c8f | 6 | void lighton() |
mfillinois | 0:7b26ada49c8f | 7 | { |
mfillinois | 0:7b26ada49c8f | 8 | ledB = 0; |
mfillinois | 0:7b26ada49c8f | 9 | } |
mfillinois | 0:7b26ada49c8f | 10 | void lightoff() |
mfillinois | 0:7b26ada49c8f | 11 | { |
mfillinois | 0:7b26ada49c8f | 12 | ledB = 1; |
mfillinois | 0:7b26ada49c8f | 13 | } |
mfillinois | 0:7b26ada49c8f | 14 | |
mfillinois | 0:7b26ada49c8f | 15 | int main() |
mfillinois | 0:7b26ada49c8f | 16 | { |
mfillinois | 0:7b26ada49c8f | 17 | ledB = 1; |
mfillinois | 0:7b26ada49c8f | 18 | button1.mode(PullUp); |
mfillinois | 0:7b26ada49c8f | 19 | button1.fall(&lighton); |
mfillinois | 0:7b26ada49c8f | 20 | button1.rise(&lightoff); |
mfillinois | 0:7b26ada49c8f | 21 | while(1) |
mfillinois | 0:7b26ada49c8f | 22 | { |
mfillinois | 0:7b26ada49c8f | 23 | |
mfillinois | 0:7b26ada49c8f | 24 | } |
mfillinois | 0:7b26ada49c8f | 25 | } |