1

I built an 8x8 led matrix using white 5mm LEDs. I drive the LEDs using the MCP23017 connected to an Arduino over the I2C bus. The wiring of the LEDs in the matrix is such that a row is made up of 8 LEDs whose cathodes are wired together, and a column is made up of 8 LEDs whose anodes are wired together. The end of each row and each column is connected to a GPIO pin of the MCP23017. The size of the pixel is 4cmx4cm which means that a row is 32 cm long (the same for a column).

I cannot get the light to be "stable", it keeps scintillating. I increased the clock frequency of the I2C bus from 100kHz to 400kHz, the light is more stable now, but not enough since the scintillation persists. Before that, I set the I2C clock frequency to 1700kH and the lighting became even slower..., I tried increasing the values of the pullup resistors of the GPIO pins of the MCP23017 to have a quicker response on its GPIO pins, but it had no effects.

enter image description here

I am thinking of 2 potential reasons:

  • The wires are too long for the I2C protocol to handle (a side of the led matrix is 32cm long).
  • the current reaching every column (the anodes) is not enough since there are so many leds to light up.

What do you think is causing this bad lighting? should I change the MCP23017 with another type of expander/protocol?

Here's the code:

#include <Wire.h>
#include <Adafruit_MCP23017.h>

bool four[3][5] = {{1, 1, 1, 0, 0}, {0, 0, 1, 0, 0}, {1, 1, 1, 1, 1}}; Adafruit_MCP23017 mcp;

void setup() { mcp.begin(); for(int i=0; i<16; i++){ mcp.pinMode(i, OUTPUT); } }

void set_column(uint8_t col_idx, bool pixels[]){

for(uint8_t i=0; i<8; i++) mcp.digitalWrite(i, HIGH);

for(uint8_t i=8; i<16; i++) //Anodes are connected to Bank B of the MCP23O17 if(i!=col_idx+8) mcp.digitalWrite(i, LOW); else mcp.digitalWrite(i, HIGH);

for(uint8_t i=0; i<8; i++) //Cathodes are connected to Bank A of the MCP23O17 if(pixels[i]) mcp.digitalWrite(i, LOW); }

void display_character(bool character[3][5]){ bool pixels[8] = {0, 0, 0, 0, 0, 0, 0, 0}; for(int col=0; col<3; col++){ for(int i=0; i<5; i++){ pixels[i+3] = character[col][i]; } set_column(7-col, pixels); } }

void loop() {

uint32_t time = millis(); while(millis() - time < 1000) display_character(four); }

S.E.K.
  • 53
  • 4

0 Answers0