1

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

1 Answer 1

3

I don't see any program statements in the code as shown to cause the described behavior, and imagine it is some hardware problem. (I'm assuming you put some non-zero values into the image[][] array; it looks to me like nothing should light up when image[][] is all-zeroes.)

Hardware problems break into several categories: A wiring problem (which we can't see without much better pictures); incorrect software setup of HW; temporary misbehavior of the processor; or permanent damage. For the sake of discussion, suppose temporary misbehavior applies.

Temporary misbehavior can be caused by overheating. Overheating can be caused by drawing or sinking a lot of current for too long a time. (If a large current is a fast transient event, it may have little effect.)

Note that most Arduino I/O lines are rated to sink or source at most 40 mA current each. Ground and Vcc lines have higher limits, like 200 or 100 mA. For more details see the spec sheet for your processor; also see ArduinoPinCurrentLimitations at arduino.cc, and Real maximum current for ATmega328? on Electronics SE.

If an LED is directly connected to 5V, it is likely to draw several times more current than nominal. Connecting an LED directly to an Arduino digital line also will allow it to draw too much current. Connecting 8 LEDs to a single processor IO line is likely to cause enough overheating to damage the processor permanently. You may need to add 8 or 16 resistors to your circuit.

Anyhow, instead of trying to debug while using a 100 μs multiplexing delay in your program, and instead of turning on lots of lights at the same time, try turning on one at a time for a brief but visible period each, and see if the array of lights scans ok, via code like the following:

int rowPins[]    = {19, 18, 11, 7, 12, 5, 4, 16}; //assign row lines
int columnPins[] = {13, 17, 9, 10,  2, 8, 3,  6}; //assign col lines

void setup() { 
  int i;          
  for (i=0; i<8; ++i) {
    pinMode(rowPins[i], OUTPUT);  
    digitalWrite(rowPins[i], HIGH);
    pinMode(columnPins[i], OUTPUT); 
    digitalWrite(columnPins[i], LOW);   
  }
}
void loop () {
  int x, y;
  for (y=0; y<8; ++y) {
    digitalWrite(rowPins[y], LOW);
    for (x=0; x<8; ++x)  {
      digitalWrite (columnPins[x], HIGH);
      delay(250);     // wait about .25 seconds
      digitalWrite(columnPins[x], LOW);
    }
    digitalWrite(rowPins[y], HIGH);
  } 
}

If multiple lights are on there may be miswiring on your project board, or the chip might be damaged, or there may be some roundabout leakage path from columns to ground or from rows to Vcc. If you make the delay longer or add a pushbutton to advance manually, you can check voltages on LEDs and wires, or measure currents in wires, and perhaps deduce what the path is.

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.
    – Erebus
    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.) 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))
    – Gerben
    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?”. Sep 11, 2014 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.