Mjerenje napona - 03.11

Dependencies:   mbed

Fork of HelloWorld by Simon Ford

Committer:
fpervan
Date:
Thu Nov 10 19:50:13 2016 +0000
Revision:
5:0406c84a3d6f
Parent:
4:01e6c90b206d
Child:
6:4c46c5ba3aa3
6.4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fpervan 2:9d203ce835e8 1 #include "mbed.h"
fpervan 4:01e6c90b206d 2 InterruptIn button(p18); // Interrupt on digital pushbutton input p18
fpervan 4:01e6c90b206d 3 DigitalOut led1(p5); // digital out to p5
fpervan 4:01e6c90b206d 4 Timer debounce; // define debounce timer
fpervan 4:01e6c90b206d 5 void toggle(void); // function prototype
fpervan 2:9d203ce835e8 6 int main() {
fpervan 4:01e6c90b206d 7 debounce.start();
fpervan 4:01e6c90b206d 8 button.rise(&toggle); // attach the address of the toggle
fpervan 4:01e6c90b206d 9 } // function to the rising edge
fpervan 4:01e6c90b206d 10 void toggle() {
fpervan 4:01e6c90b206d 11 if (debounce.read_ms()>200) // only allow toggle if debounce timer
fpervan 4:01e6c90b206d 12 led1=!led1; // has passed 200 ms
fpervan 4:01e6c90b206d 13 debounce.reset(); // restart timer when the toggle is performed
fpervan 5:0406c84a3d6f 14 }