Trying to use Pro Micro's internal pullup resistors

Hi, I am trying to make a number pad and I’ve been having trouble using the INPUT_PULLUP mode with my Cherry MX clones. I’m pretty sure it’s not code because when I touch ground to the pin, it behaves as I would expect, but I’ll include it anyway.

I couldn’t get any pins to work. I tried using 8, 9, 10, 14, and 15. I tested by attaching one switch pin to one board pin and just clicking. Nada.

There is continuity between the switch pin and the board. I tested with a multimeter.

Is there anything else I should be doing to make internal pullup resistors work? What are my next troubleshooting steps?

Here’s the code as well

const int pin = 8;

void setup() {
  Serial.begin(9600);
  pinMode(pin, INPUT_PULLUP);
}
 
void loop() {
  bool buttonState = digitalRead(pin);
  if (buttonState == LOW) {
      Serial.print("h");
  }
}

The schematic is not helpful

Exactly how is pin 8 wired ?

I used solder for both the pin on the board and on the switch.

I meant what is connected to pin 8 ? From what you say you have a wire from pin 8 to the switch but where does the other side of the switch connect to ?

Oh, oops. I have a diode on the other pin going to pin 9.

Why the connection to pin 9 when it is not even used in your program ?

By the way, please do not edit posts that have already been commented on. I have updated post #1 with your revised "schematic"

The first way I tried to test the switch was with the diode and pin 9, and I just left it there. Does it hurt anything to have it in?

Also, sorry. I didn't know the etiquette for the forums.

Take out the diode, forget about pin 9.
Use a pinMode() of INPUT_PULLUP on pin 8 and wire it to take pin 8 LOW when the switch is closed. Print the output of digitalRead(8 )

digitalRead(8)

What do you see ?

EDIT - added code tags to get rid of the smiley

All 1s in the monitor.

riorioria:
All 1s in the monitor.

Even when you take pin 8 LOW ?

Yes. Checked with the multimeter, the voltage just doesn't change when pressed. It has to be a wiring issue of some sort. It seems to work okay with just INPUT, but that might just be interference with my hand. The solder joints certainly aren't cold. Good contact is also being made. Am I just doing it completely wrong?

I know it's a nuisance, but please post the code that you are testing and confirm that there is simply a wire from pin 8 to the switch then from the other terminal of the switch to GND, no diode and no connection to anything else

Hi,

What is the voltage that you get from pin 8, with the button pressed and not pressed?

What is your press button?
How many terminals does it have?

Can you post a picture of your project to show your component layout.

If you are using a tactile button with four terminals, use your DMM to find the two terminals that act as a switch.

Try this code and see what the IDE monitor displays when you press the button.

const int pin = 8;
bool buttonState;
void setup() {
  Serial.begin(9600);
  pinMode(pin, INPUT_PULLUP);
}

void loop()
{
  buttonState = digitalRead(pin);
  if (buttonState == LOW)
  {
    Serial.println("Button Pressed");
  }
  else
  {
    Serial.println("Button Not Pressed");
  }
}

This is how you should have your switch wired;


Thanks.. Tom.. :slight_smile:

I suppose I should post what I did to resolve my issue. I went about my day and realized I skipped the first step in troubleshooting: turning your device off and on again. It was the most bizarre thing. When I reset my laptop, I used the same code as I had before, ground pin and 8 pin were left as they were, but when I uploaded the code again, I saw voltage going from 4.5V to 0.

Is this even a real solution? Did I just hallucinate it not working this whole time?

Anywho, after seeing one switch work, I finished the number pad. It works, albeit with a couple bugs (multiple key presses sends garbage and breaks inputs). Thanks for the help you guys.

Oh, and for clarification, I had pin 9 and the diode attached at first because I'm a clown and thought I could connect to ground from any of the digital pins without code. By post #7, I swapped out the diode and pin 9 for plain wire and the ground pin, had issues, restarted my computer, and it worked like magic.