Pages: [1]   Go Down
Author Topic: 8x8 Led matrix programing issue?  (Read 1219 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/*
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();
}
« Last Edit: March 25, 2013, 11:53:49 am by szaboa1 » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25712
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you remember putting italics in your code?
No, I thought not.
Please read this
Logged

"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.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 143
Posts: 5309
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Logged

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25712
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I changed it to 'byte'. What can I use instead of delay() ?
Code:
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},
};
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25712
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need help, please smiley
Logged

Offline Offline
Faraday Member
**
Karma: 58
Posts: 2778
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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 ;
    }
}

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.. smiley-confuse
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26359
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Pages: [1]   Go Up
Jump to: