Hello, a newbie here. I am trying to make 4-digit 7-segment display to work along with MCP23017, which I am using as I/O expander. The display is directly attached to Arduino Micro, it is common anode type. It shall just to count down an amount of time, regardless of MCP23017 ( this will be used later for buttons and relays).
All works good without MCP23017 , also the times counts down, until i attach SCK/SDA lines to MCP23017. The display freezes in some strange state (always different). Starting the adruino with MCP23017 attached, is worse, the display shows nothing.
MCP23017 has its own 5V from battery, i checked it also without battery.
First the display.
Connect the display and remove everything else from the Arduino board.
Which SevSeg library do you use ?
Can you give a link to your display (a link to where you bought it).
You might need resistors for each segment.
Then the I2C I/O expander
Remove the display from the Arduino board.
Please use the 5V from the Arduino board.
Can you draw a schematic with the wiring ?
Can you show a photo, so I can see if you use a long cable or a flat ribbon cable for the I2C bus.
You may not use the MCP23017 before initializing it. Look at examples from Adafruit how they use the library with "mcp.begin_I2C()": https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/blob/master/examples/mcp23xxx_blink/mcp23xxx_blink.ino
If you fix the sketch, does it work on its own ?
Possible causes
There are many possible cause. The more information you give, the faster we can pinpoint the cause.
At this moment I'm thinking of the bug with "mcp.begin_I2C()", or perhaps a low voltage due to the display, or a shortcut on the I2C bus, or missing power for the MCP23017.
Can you give a reference to that ? It is such a bold claim.
Wow, thanks for such a rapid feedback! Thank you, i wasnt expecting that!
I have read all your answers - and it helped. My calim was not correct, but most important is that all works now. Well, not as expected, the display flickers... I am sorry for not providing any sketch, i will try to make it until the end of week, for the future seekers.
First - I added pullup resistors, as J-M-L suggested. I used 4,7 kOhm. I did not see them on examples from internet, so i did not know about them. It helped.
Then i used 5V from Arduino (thx Koeppel) and that all together solved my issues. I also fixed the sketch, as suggested.
I am posting one photo, its full of wires, so you cannot see a lot. The display flickers a lot, the more buttons I am adding, the more delay i have. I am currently switching buttons directly to Arduino, looks like it helps with the issue ( faster response than from MCP23017).
That is looking good The photo is too small and you should not use a yellow wire for the GND, but it is looking good
The 7 segment displays are not just turned on and off. Each segment is turned on for a short time. The loop() should run hundreds or thousand times per second to avoid that you can see flickering.
Do you have a multimeter (also called a DMM) ?
Can you check the 5V voltage ? The relays and the display could draw too much current.
Thank you very much for your support. I decided to use a standard 16x2 display, with I2C bus. Much more easier for me, without flickering and just two wires.