![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Grove Starter Kit for mbed - Button
main.cpp@0:c48d7e51d9c9, 2015-02-16 (annotated)
- Committer:
- lingtien5846
- Date:
- Mon Feb 16 10:59:24 2015 +0000
- Revision:
- 0:c48d7e51d9c9
- Child:
- 1:f93ac9d8770c
Grove Starter Kit for mbed - Button
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lingtien5846 | 0:c48d7e51d9c9 | 1 | #include "mbed.h" |
lingtien5846 | 0:c48d7e51d9c9 | 2 | |
lingtien5846 | 0:c48d7e51d9c9 | 3 | DigitalOut myled(LED1); |
lingtien5846 | 0:c48d7e51d9c9 | 4 | DigitalIn button(p21); |
lingtien5846 | 0:c48d7e51d9c9 | 5 | |
lingtien5846 | 0:c48d7e51d9c9 | 6 | int main() { |
lingtien5846 | 0:c48d7e51d9c9 | 7 | while(1) { |
lingtien5846 | 0:c48d7e51d9c9 | 8 | if (button) { |
lingtien5846 | 0:c48d7e51d9c9 | 9 | myled = 1; |
lingtien5846 | 0:c48d7e51d9c9 | 10 | } |
lingtien5846 | 0:c48d7e51d9c9 | 11 | else |
lingtien5846 | 0:c48d7e51d9c9 | 12 | myled = 0; |
lingtien5846 | 0:c48d7e51d9c9 | 13 | |
lingtien5846 | 0:c48d7e51d9c9 | 14 | wait(0.7); // simple debouncing |
lingtien5846 | 0:c48d7e51d9c9 | 15 | } |
lingtien5846 | 0:c48d7e51d9c9 | 16 | } |