Skip to main content
Arduino

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

8X8 LED not lightning up according to matrix assignment on a Arduino Nano

I'm currently trying to code a simple program that would allow me to light up an individual LED on an 8X8 LED board using a double array.

Here are the problems:

All the rows can ON individually UNTIL I turn all 8 rows ON. When I do this the last column turns OFF by itself (see attached pictures).

The columns aren't even working properly either. Every time I assign a column ON, the last column faintly turns ON too (one of the LEDs light in that column is broken so that is expect to be OFF. See picture).

I think those are the reasons why I am not able to singly assign a particular LED to be ON according to assignments in the array. If someone could spot my mistakes, it would greatly be appreciated. Thanks!

int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int led8 = 8;
int led9 = 9;
int led10 = 10;
int led11 = 11;
int led12 = 12;
int led13 = 13;
int led16 = 16;
int led17 = 17;
int led18 = 18;
int led19 = 19;
int rowPins [8] ={led19, led18, led11, led7, led12, led5, led4, led16};//assigning each LED to a row.
int columnPins [8] ={led13, led17, led9, led10, led2, led8, led3, led6};//assigning each LED to a column
int image [8][8]=
{
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
};
void setup() 
{ 
 for (int i = 0; i<8; i++) 
 {
 pinMode(rowPins[i], OUTPUT); 
 pinMode(columnPins[i], OUTPUT); 
 }
}//end of setup() 
void loop ()
{
for (int y=0; y<8; y++)
{
 for (int x=0; x<8; x++)
 {
 if (image[x][y]==1)
 {
 digitalWrite (columnPins[x], HIGH);
 }
 else
 {
 digitalWrite(columnPins[x], LOW);
 } 
 }//end of 2nd for loop 
 digitalWrite(rowPins[y], LOW);
 delayMicroseconds(100);
 digitalWrite(rowPins[y], HIGH);
}//end of first for loop
}//end of loop

When all 8 rows are ON the last column turns OFF

When only 7 rows are ON

when one column is ON the other is faintly also ON

Answer*

Draft saved
Draft discarded
Cancel
4
  • Thanks for the inputs jwpat7. I really appreciate it. The image [][] array was set to 0s just to show how I set it up. However, I would have put 1's in the array if I wanted to run the LED board. So sorry for not showing those other arrays. I think you might be right in that the problem I'm having might be because of wiring on the board. I copied and ran your example code, however there's always two LEDs ON as it goes through the array. It should have just shown one LED at a time according to your code right? Otherwise, it must be the wiring. Commented Sep 10, 2014 at 16:06
  • Erebus, the intent was to have 1 light on at a time, but I noticed I didn't initialize the pins. I've added two digitalWrite() statements in setup(). (All the pins would have been initialized anyway after the first pass thru loop() so it might not make any difference.) Commented Sep 10, 2014 at 20:01
  • You definitely need to add resistors. Since you need to power 8 leds with one pin you need to limit the current to each led to 5mA (40/8), or add a transistor to each row/column (depending on the type of matrix (common cathode/common anode)) Commented Sep 11, 2014 at 18:23
  • Also, instead of having column lines sitting LOW when off and row lines sitting HIGH, I would tri-state lines not being used (ie would say digitalWrite(pin#,LOW); pinMode(pin#,INPUT); when done with a pin). See eg forum.arduino.cc Reply #2 re "Tri-state logic on IO pins?". Commented Sep 11, 2014 at 18:37

AltStyle によって変換されたページ (->オリジナル) /