I'm trying some basic things with a Nucleo F401RE, and I cannot get the most simplistic DebounceIn working. In this case I'm simply setting the LED to the button state. This works perfectly fine using DigitalIn to read the button state:
#include "mbed.h"
#include "DebounceIn.h"
DigitalOut myled(LED1);
DigitalIn pb(PC_13);
int main() {
pb.mode(PullUp);
while (1) {
myled=!pb.read();
}
}
As long as the button is pressed, the LED illuminates. Now if I simply change the type of pb to DebounceIn, then pb.read() always returns false and thus the LED is always on:
#include "mbed.h"
#include "DebounceIn.h"
DigitalOut myled(LED1);
DebounceIn pb(PC_13);
int main() {
pb.mode(PullUp);
while (1) {
myled=!pb.read();
}
}
I've tried adding a wait in the loop, commented out the code that enables the internal pull up resistor, etc, and it simply does not work correctly with DebounceIn. Any suggestions would be greatly appreciated.
PS, the mbed library is the most recent - version 89.
I'm trying some basic things with a Nucleo F401RE, and I cannot get the most simplistic DebounceIn working. In this case I'm simply setting the LED to the button state. This works perfectly fine using DigitalIn to read the button state:
As long as the button is pressed, the LED illuminates. Now if I simply change the type of pb to DebounceIn, then pb.read() always returns false and thus the LED is always on:
I've tried adding a wait in the loop, commented out the code that enables the internal pull up resistor, etc, and it simply does not work correctly with DebounceIn. Any suggestions would be greatly appreciated. PS, the mbed library is the most recent - version 89.