I am working with an Arduino nano, and ic2 128x32 OLED display and a 1x4 membrane keypad. Problem is that only one of the 4 pins are detecting the button press. it's not the Arduino, I already was able to reproduce the same issue on another one. the keypad is also working fine, as I have tested it. (edit now only pin 9 is working)

#define b1 6
#define b2 7
#define b3 8
#define b4 9

// in setup

pinMode(b1, INPUT_PULLUP);
pinMode(b2, INPUT_PULLUP);
pinMode(b3, INPUT_PULLUP);
pinMode(b4, INPUT_PULLUP);

// in loop

int b1S = digitalRead(b1);
  int b2S = digitalRead(b2);
  int b3S = digitalRead(b3);
  int b4S = digitalRead(b4);

    Serial.println("Button 1");

    Serial.println("Button 2");

    Serial.println("Button 3");

    Serial.println("Button 4");

Please help! Thanks

  • How is everything connected? Have you measured, if there is 5V on the specified pins, when you don't press a button? Also measure without the keypad – chrisl Aug 26 '19 at 13:58
  • to answer how its connected, each pin defined in the code is connected to one of the inputs of the buttons on the keypad with it all connected to a common ground – Avi Baruch Aug 26 '19 at 14:05
  • and b2 and b4 are giving around 4v and the other 2 are giving readings somewhere in the millivolts, that's not right, right? – Avi Baruch Aug 26 '19 at 14:08
  • I'd suggest backing up and testing each part separately. Get a breadboard and a momentary switch. Connect the switch through to ground on one pin at a time. See if a test sketch is able to detect the change in state for each pin when it's configured as INPUT_PULLUP. If not, try using INPUT, and attaching the pin to +5V through a 10kΩ resistor. Also use an ohm-meter to verify that your membrane switches are open unless pressed, and connect to ground when they are pressed. – Duncan C Aug 26 '19 at 14:48
  • 1
    Have you measured these voltages with connected keypad? If yes, try without the keypad - just the bare arduino. If the voltages are still that low, the Arduino is probably broken. – chrisl Aug 26 '19 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.