-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Arising from support ticket https://support.microbit.org/helpdesk/tickets/93871 (private)
When an unconnected croc lead is attached to P0/1/2 the first digital read sees high rather than low.
In this example the first A press shows a sad face (NB: testing P1, though P0 and P2 are the same)
https://makecode.microbit.org/_bLeeKP2HohFw

This is more like the ticket example: https://makecode.microbit.org/_bAPWrzXghiu1
C++ example (press A): test-digitalread.zip
When tested with just one croc lead, it's enough to move setPull before setting input mode, but with a chain of croc leads. a longer delay seems to be required:: e.g. target_wait(1) after setPull.
https://github.com/lancaster-university/codal-nrf52/blob/master/source/NRF52Pin.cpp#L291
I haven't found an example that triggers a wrong value except the very first after reset. V1 is OK.
This is related, though maybe not the actual explanation!
https://devzone.nordicsemi.com/f/nordic-q-a/36881/best-practice---delay-between-setting-pin-as-input-with-pull-up-pull-down-and-reading-the-pin