MIDI Shield Buttons Stopped Responding

I have the MIDI Shield attached to the Uno and was working through a project that uses the buttons on the MIDI Shield. Things were working fine, but those buttons no longer seem to produce output when querying them with digitalRead().

What would be causing the buttons to no longer respond?

These are the D2, D3, and D4 buttons that I am checking with digitalRead(2), and so on. For example:

int reading = digitalRead(2);

The value for "reading" will always be 0, regardless whether the button was pressed or not.

What am I missing?

Well, it looks like using INPUT_PULLUP instead of just INPUT with the pinMode seems to be the issue.

Using just INPUT as in the following:

pinMode(buttonPin, INPUT);

does not change the value returned from digitalRead(buttonPin). It will always be 0 no matter whether the button is pressed or not. However, using INPUT_PULLUP would produce 1 when the button is not pressed and 0 when it is pressed.

I’m sure this is expected behavior, but I’m not certain why INPUT wouldn’t produce 1 when the button is pressed and 0 when it is not.

If you look at some wiring examples, there are two ways to wire a digital input. A pull up or a pull down resistor.

Here is a link to a schematic of a pull down; When the switch is not pressed, the pin is pulled down to 0 volts through the resistor. When the switch is pressed, the pin is connected to 5V and is high.

A pull up works the opposite (both internal and external pull up resistors). The pin is pulled to 5 volts through the resistor when the switch is not pressed. When the switch is pressed, the pin is connected to ground and reads low.

Thanks, Nathan.

What you described is what I would expect. Means that using INPUT instead of INPUT_PULLUP would produce just the opposite results. I'll have to look at the MIDI Shield specs more closely, but I would expect a button press when using INPUT to produce a HIGH value, which in my situation it doesn't. It stays LOW.

What Midi shield are you using? I looked at a couple of schematics on line and the ones I looked at had the switches pulling the pins low. The code would use the internal pull up in that configuration.

Yup, that's what is happening here. I'm using the SparkFun MIDI Shield. So, you're correct.