Go Down

Topic: Arduino multi functional, circuit issues with MAX7221 RESOLVED (Read 123 times) previous topic - next topic


I have an Arduino UNO that I have set up to perform a number of functions together with a RPI via the USB.

- get data from the RPI
- show data on a 3 seven segment displays and led's using a MAX7221cng
- detect if a push-button state changed and drive a relais if it did
- detect the status of a PIR and drive a LED (not important here, just a fyi)

Yeah, a lot.

The issue that I was facing what that the MAX7221 went into never-never land if the button was pushed.

The push-button detection was the usual where the pin I was monitoring was pulled low to ground via a resistor and the became high when the button was pushed (closing a 5v circuit). The Arduino kept on trucking but the MAX7221 chip just lost track and never came back. Random LED segments lighted up from that point on.

It seems that when the button was pushed the ground looped back into the MAX7221. It found that route the shortest path to the higher potential for some reason.

I had to put a diode (1N4001) in series with the ground of the MAX7221 blocking the unwanted ground-to-chip flow. The diode is invisible for the MAX chip towards the ground and prevented a backflow.


That sounds like it is not fixed at all, but the description is very confused.  :smiley-roll-sweat:


Let me try again.

You first need to be aware of how a push-button is detected in the Arduino.  Check this: https://www.arduino.cc/en/tutorial/button

You will see that the pin you are monitoring is pulled down to the ground via a resistor. This makes sure it has a low-state. When the button is pressed the pin gets 5V and is high-state which we can detect in the sketch.

But ... there will be a current flowing to the ground via the resistor when you push the button. The ground will temporarily have a higher potential. That potential will want to flow to somewhere that has a lower potential if it can find a path, that is how circuits work. If you have something connected to the same ground then that might open a path to a lower potential. In my case, that was something internal to that MAX7221 chip, possibly via the LED segments it was driving. The current went back up the ground contact of the chip to who knows where and that threw the chip into a weird state.

A diode acts as a one way street for current, it can only flow in one direction. I put a diode into the ground connection of the chip, only allowing current to flow to the ground. The reverse current created by a temporary higher potential in the ground was blocked off.

Now, a further complication might have been created because the chip-to-ground current would temporarily have been blocked by the higher potential in the ground of the Arduino, which would have let the chip to fail as well. I already had a capacitor in the circuit that allowed for the ground of the MAX chip to "charge" it. The circuit was not interrupted, it had a path to a lower potential for that brief moment.

Current is like water, it will want to flow to the lowest point. I put in a dam to block the water from flowing where I did not want it to.


Try this instead:
1. Get rid of the pulldown resistor.
2. Wire the button to connect the pin to Gnd when it is pressed.
3. Enable the internal pullup resistor.
4. Change your code to react to a Low instead of a High.

before setup():
byte pinX = 2; // whatever pin you are using
byte pinState;

In setup():
pinMode (pinX, INPUT_PULLUP);

In loop():
pinState = digitalRead (pinX);
if (pinState == LOW){
// button was pressed, do something

if (digitalRead (pinX) == LOW){
// button was pressed, do something

or however your sketch act when it sees a High.

Much less current is switched with the internal pullup, there will be no upset of external devices.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up