Strange... Your wiring looks ok, but I just had a thought:
Is the pullup resistor you have actually connected and working? Maybe try pinMode(A8, "input_pullup") to use the STM32's internal pullup resistor just in case?
Because it could be that when you close the reed switch, that's fine and you get a 0. But when you open it, the pullup isn't there and it just 'floats' - which would mean that you get all kinds of readings - and potentially setWatch with debounce would rarely actually register that the signal went high.
One other thing to try is to put small (0.1uF?) capacitor across the reed switch. It shouldn't be needed, but it would stop the signal changing so frequently and causing problems.
© Espruino, powered by microcosm.
Report a problem