Open david284 opened 2 years ago
I can confirm that the Keypad library does not work with a Raspberry Pi Pico, and also kills I/O pullups.
The Raspberry Pi Pico in normal Arduino mode is on top of Mbed. The definition of INPUT_PULLUP is removed, and the INPUT_PULLUP is placed in a enum. See: https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/RASPBERRY_PI_PICO/pinmode_arduino.h
In case the INPUT_PULLUP was missing, a fix was added in Keypad.h: https://github.com/Chris--A/Keypad/blob/master/src/Keypad.h
The fix is from 2013. It brings back the definition for INPUT_PULLUP which is wrong for a Raspberry Pi Pico, then it does not use a pinMode(_pin,INPUT_PULLUP);
but a pinMode(_pin, INPUT); digitalWrite(_pin, 1);
which does not result into a pullup for the pin.
After locally changing that line to pinMode(_pin,INPUT_PULLUP);
instead of pinMode(_pin, INPUT); digitalWrite(_pin, 1);
the keypad works fine on the Pico.
I have a raspberryPi Pico (based on RP2040), and when I just include the library (i.e. don't reference any functions or define any I/O's), I/O that have been defined as pull-ups no longer have a pull-up for example in setup(), I have
pinMode(14, INPUT_PULLUP);
So, before adding
#include <keypad.h>
GP14 reads a steady 3.2v with a multimeter after adding just#include <keypad.h>
GP14 now reads a varying value around 140mVIt's affecting the actual pins for the key matrix, as I first noticed that when I had the full code for one of the examples, just touching the pins caused key presses to be registered - a sure sign of lack of pull-ups
I don't understand why it should be affecting other IO pins not used by the keypad library, but it seems to affect them all I realise I could add pullups to the actual kaypad matrix, but more worried that it affects other pins that I intend to use for other features that rely on internal pullups working
My apologies if I've missed something obvious
I'm using PlatformIO inside VSCode if that makes any difference and have
lib_deps = chris--a/Keypad@^3.1.1
in platformio.iniMy entire program is below, with the majority commented out