Go Down

Topic: 8x8 Led matrix programing issue? (Read 1 time) previous topic - next topic

szaboa1

Mar 25, 2013, 09:44 am Last Edit: Mar 25, 2013, 05:53 pm by szaboa1 Reason: 1
Hi there,

I have started this project, and I thin i have a problem with the programing part.
So belove you can check out my code. The problem is when I put a little delay(e.g. 1 to 10) the LEDs brightness is low, and they start to blink at one point. Also if the value is high like in this code, the brightness is ok, but of course i don't have the continuos "flow" to get for example the letter A. My goal is to display a letter with no blinking and good brightness.
(The pins are correctly mounted, i checked several times, also i have a basic setup 8x8 Led matrix, with comon catodhe setup, each anode coloumn beeing protected by a 220 ohm resistor)
Code: [Select]

/*
8x8 Led Matrix using Arduino
*/

int i=0, j=0;
int l_col=8;
int l_row=8;
int col[8] = {13,12,11,10,9,8,7,6};
int row[8] = {19,18,17,16,5,4,3,2};

int pattern[8][8] = {
 {0,1,1,1,1,1,1,0},
 {0,1,0,0,0,0,1,0},
 {0,1,0,0,0,0,1,0},
 {0,1,0,0,0,0,1,0},
 {0,1,1,1,1,1,1,0},
 {0,1,0,0,0,0,1,0},
 {0,1,0,0,0,0,1,0},
 {0,1,0,0,0,0,1,0},
};

void setup() {
 for(i=0; i<l_col; i++)
 {
   pinMode(col[i], OUTPUT);
   digitalWrite(col[i], LOW);
 }
 for(i=0; i<l_row; i++)
 {
   pinMode(row[i], OUTPUT);
   digitalWrite(row[i], HIGH);
 }
}

void draw(){
 for(i=0; i<l_row; i++)
 for(j=0; j<l_col; j++)
 {
   if(pattern[i][j])
   {
     digitalWrite(col[j], HIGH);
     digitalWrite(row[i], LOW);
     delay(500);
     digitalWrite(col[j], LOW);
     digitalWrite(row[i], HIGH);
   }
 }
}

void loop() {
 draw();
}

AWOL

Do you remember putting italics in your code?
No, I thought not.
Please read this
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

fungus

"delay()" is the devil's function. You need to exorcise it from the code.


No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

AWOL

Code: [Select]

int pattern[8][8] = {
  {0,1,1,1,1,1,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,1,1,1,1,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,0,0,0,0,1,0},
};

Using 128 bytes of precious RAM to store eight bytes-worth of data is not a good use of resources.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

szaboa1

I changed it to 'byte'. What can I use instead of delay() ?
Code: [Select]

byte pattern[8][8] = {
  {0,1,1,1,1,1,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,1,1,1,1,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,0,0,0,0,1,0},
  {0,1,0,0,0,0,1,0},
};

AWOL

Quote
I changed it to 'byte'.

So down from a 16x overhead to only an 8x overhead.
Keep going.

Quote
What can I use instead of delay() ?

Have a look at the blink without delay example, provided with the IDE.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

szaboa1

I don't know how to use that example for my 8x8 led matrix..yet. Turn on an led, wait, turn off that led, wait, turn the next led...something like this?
Without delay, the brightness will be ok?:)

szaboa1


michinyon

So to do your 64 outputs,  with half a second delay for each one,  will take 32 second per cycle.
That's never going to work.

If I was going to drive leds that way,  I'd try something like this

Code: [Select]

int n_on ;
int ons[8] ;
for ( int k=0 ; k<8 ; k++ )
{
    ons[k]=0 ;
}

for ( int j=0 ; j<8 ; j++ )
{
    for ( int i=0 ; i<8 ; i++ )
    {
        if ( pattern[i][j] )
        {
            ons[n_on]=i ;
            n_on++ ;
            digitalWrite( row[i], HIGH );
        }
    }
    if ( n_on > 0 )
    {
        digitalWrite( col[j], LOW );
        delay(15) ;
        digitalWrite( col[j], HIGH );
        for ( int m=0 ; m<n_on ; m++ )
        {
            digitalWrite( row[ons[m]], LOW );
        }
        n_on=0 ;
    }
}


szaboa1

The code is working, I can see the pattern but the brightness is low again..how can I fix the brightness problem? With 'delay(150)' the brightness is ok.. :~

szaboa1

Someone can help me? I just made a GUI in processing to control the leds. I can't figure it out this brightness problem..

CrossRoads

Increase the cycle time, and decrease the current limit resistor. Thus you cycle thru the LEDs faster, but they are brighter when they are on.  Check the datasheet for the part, see how long each can be on when pulsed, and what the pulse current can be.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Go Up