Implement Debounce Function for SPDT Switch on Mbed NXP LPC1768 | shiroku.Net
Environment Host PC: Ubuntu 18.04 Device: mbed NXP LPC1768 Switch: EG2350-ND Experiment to Measure a Chattering Event mbedLearning/main.cpp at master · shirokunet/mbedLearning The result is depends on switch mode such as pullup and pulldown. But the chattering time I detected is about ~800 usec. PullUp Mode PullDown Mode How to Implement Debounce Function Basically, when using a switch or a relay, chattering will be caused. To solve this problem, two solution can be used. One is create a LPF circuit using a resistor and a capacitor. It cuts high frequency noise such as chattering. However, we have to change hardware. Another solution is counting time after detect rise edge using interrupt on the software. This implementation is easier than LPF. But we have to care about using this solution because interrupt function can interference other function. I chose second solution which is using software. mbedLearning/DebounceSPDT/main.cpp 10th Count Application Here is example of count