Matija Cecić
/
VjezbaV5_1
6.4 Tipkalo
main.cpp@0:63d97baa8786, 2016-11-10 (annotated)
- Committer:
- MatijaCecic
- Date:
- Thu Nov 10 18:24:29 2016 +0000
- Revision:
- 0:63d97baa8786
VT2 Matija_Ceci?
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MatijaCecic | 0:63d97baa8786 | 1 | #include "mbed.h" |
MatijaCecic | 0:63d97baa8786 | 2 | InterruptIn button(p18); // Interrupt on digital pushbutton input p18 |
MatijaCecic | 0:63d97baa8786 | 3 | DigitalOut led1(p5); // digital out to p5 |
MatijaCecic | 0:63d97baa8786 | 4 | void toggle(void); // function prototype |
MatijaCecic | 0:63d97baa8786 | 5 | int main() |
MatijaCecic | 0:63d97baa8786 | 6 | { |
MatijaCecic | 0:63d97baa8786 | 7 | button.rise(&toggle); // attach the address of the toggle |
MatijaCecic | 0:63d97baa8786 | 8 | } // function to the rising edge |
MatijaCecic | 0:63d97baa8786 | 9 | void toggle() |
MatijaCecic | 0:63d97baa8786 | 10 | { |
MatijaCecic | 0:63d97baa8786 | 11 | led1=!led1; |
MatijaCecic | 0:63d97baa8786 | 12 | } |