LED DOT MATRIX DIRECT FROM ANO :)

Hi first sorry for my ENG. Really Big Sorry

iv got a problem im fighting wit this all week.

first i adapt code ::

byte A[] = {
  B00111100,
  B01100110,
  B11000110,
  B11000110,
  B11000110,
  B11111110,
  B11000110,
  B11000110};

byte R[] = {
  B11111000,
  B11000110,
  B11000110,
  B11000110,
  B11000110,
  B11011100,
  B11001100,
  B11000110};
  
byte D[] = {
  B10000000,
  B10000000,
  B10000000,
  B10000000,
  B10000000,
  B10000000,
  B10000000,
  B10000000};


const int columnPins[] = { 13,12,11,10,9,8,7,6}; //wartosc oryginalna
//const int columnPins[] = { 6,7,8,9,10,11,12,13}; //wartosc zmieniona
//const int rowPins[]   = { 5,4,3,2,15,16,17,18}; //wartosc oryginalna
const int rowPins[]   = { 18,17,16,15,2,3,4,5}; //wartosc zmieniona

void setup() {
  int i =0;
  for ( i = 0; i < 8; i++)
  {
    pinMode(rowPins[i], OUTPUT);        // make all the LED pins outputs
    pinMode(columnPins[i], OUTPUT);
    digitalWrite(columnPins[i], HIGH);  // disconnect column pins from Ground
  }
}

void loop() {
  int pulseDelay = 1 ;          // milliseconds to wait between beats

 //show(smallHeart, 80);           // show the small heart image for 100 ms
  show(A,2000);
  show(R,2000);
  show(D,2000);
  // followed by the big heart for 200ms
  delay(pulseDelay);              // show nothing between beats
}


// routine to show a frame of an image stored in the array pointed to by the
// image parameter.
// the frame is repeated for the given duration in milliseconds
void show( byte * image, unsigned long duration)
{
 unsigned long start = millis();            // begin timing the animation
 while (start + duration > millis())        // loop until the duration period has passed
  {
    for(int row = 0; row < 8; row++)
    {
      digitalWrite(rowPins[row], HIGH);          // connect row to +5 volts
      for(int column = 0; column < 8; column++)
      {
        boolean pixel = bitRead(image[row],column);
        if(pixel == 1)
        {
          digitalWrite(columnPins[column], LOW);  // connect column to Gnd
        }
        delayMicroseconds(300);                   // a small delay for each LED
        digitalWrite(columnPins[column], HIGH);   // disconnect column from Gnd
      }
      digitalWrite(rowPins[row], LOW);            // disconnect LEDs
    }
  }
}

to my Arduino is working fine just perfect , but when im trying with flying message is not working only random dots are showing
please maybe some of more experience people will help me.

this code

is only a part but is making me crazy

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};

// col[xx] of leds = pin yy on led matrix
int cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

// row[xx] of leds = pin yy on led matrix
int rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};

is part of code from arduino website with FT.1.

and when i change the col and row to my one is not working

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};

i dont get it why is there pin 17 in originally code when this pin is not even used please help and why the pins are set in this order please help.

Please modify that post so the code is not mangled by the forum. It needs to be enclosed in tags. Please read the how to use this forum sticky post to find out how.

Sorry for that. iv change the post.

abrahita:
Sorry for that. iv change the post.

Thanks :slight_smile:

but when im trying with flying message is not working

By flying do you mean scrolling?
Is that code the one that works or the one that doesn't?

If it is the working code can you please post the attempt you made to scroll the text.
Thanks.

Hello again yes i is scrolling

this is code

/*
 * Show messages on an 8x8 led matrix,
 * scrolling from right to left.
 *
 * Uses FrequencyTimer2 library to
 * constantly run an interrupt routine
 * at a specified frequency. This
 * refreshes the display without the
 * main loop having to do anything.
 *
 */

#include <FrequencyTimer2.h>

#define SPACE { \
    {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} \
}

#define H { \
    {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}, \
    {0, 1, 0, 0, 0, 0, 1, 0}  \
}

#define E  { \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}  \
}

#define L { \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}  \
}

#define O { \
    {0, 0, 0, 1, 1, 0, 0, 0}, \
    {0, 0, 1, 0, 0, 1, 0, 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, 0, 0, 0, 0, 1, 0}, \
    {0, 0, 1, 0, 0, 1, 0, 0}, \
    {0, 0, 0, 1, 1, 0, 0, 0}  \
}

byte col = 0;
byte leds[8][8];

//const int columnPins[] = { 6,7,8,9,10,11,12,13};
//const int rowPins[]   = { 5,4,3,2,15,16,17,18};


// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 18,17,16,15,2,3,4,5,13,12,11,10,9,8,7,6};

// col[xx] of leds = pin yy on led matrix
int cols[8] = {pins[6], pins[7], pins[8], pins[9], pins[10], pins[11], pins[12], pins[13]};

// row[xx] of leds = pin yy on led matrix
int rows[8] = {pins[5], pins[4], pins[3], pins[2], pins[15], pins[16], pins[17], pins[18]};

const int numPatterns = 6;
byte patterns[numPatterns][8][8] = {
  H,E,L,L,O,SPACE
};

int pattern = 0;

void setup() {
  // sets the pins as output
  for (int i = 1; i <= 16; i++) {
    pinMode(pins[i], OUTPUT);
  }

  // set up cols and rows
  for (int i = 1; i <= 8; i++) {
    digitalWrite(cols[i - 1], LOW);
  }

  for (int i = 1; i <= 8; i++) {
    digitalWrite(rows[i - 1], LOW);
  }

  clearLeds();

  // Turn off toggling of pin 11
  FrequencyTimer2::disable();
  // Set refresh rate (interrupt timeout period)
  FrequencyTimer2::setPeriod(2000);
  // Set interrupt routine to be called
  FrequencyTimer2::setOnOverflow(display);

  setPattern(pattern);
}

void loop() {
    pattern = ++pattern % numPatterns;
    slidePattern(pattern, 60);
}

void clearLeds() {
  // Clear display array
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      leds[i][j] = 0;
    }
  }
}

void setPattern(int pattern) {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      leds[i][j] = patterns[pattern][i][j];
    }
  }
}

void slidePattern(int pattern, int del) {
  for (int l = 0; l < 8; l++) {
    for (int i = 0; i < 7; i++) {
      for (int j = 0; j < 8; j++) {
        leds[j][i] = leds[j][i+1];
      }
    }
    for (int j = 0; j < 8; j++) {
      leds[j][7] = patterns[pattern][j][0 + l];
    }
    delay(del+1000);
  }
}

// Interrupt routine
void display() {
  digitalWrite(cols[col], LOW);  // Turn whole previous column off
  col++;
  if (col == 8) {
    col = 0;
  }
  for (int row = 0; row < 8; row++) {
    if (leds[col][7 - row] == 1) {
      digitalWrite(rows[row], LOW);  // Turn on this led
    }
    else {
      digitalWrite(rows[row], HIGH); // Turn off this led
    }
  }
  digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
}

[/code}

i'm trying using with my 8x8 matrix direct from arduino i don't want to use m7219  for now.

i'm changing pins on row and col. like iv got col 1 rwo1 col 2 etc.

and is not working i will post you tube movie to show what iv got on screen but the first code is working fine , and when trying with this is not working and the pins are correctly 


and i don't understand the pin[xx] why the are on this order

movie got first code and the last code with scrolling

I assume you got the code from here
http://playground.arduino.cc/Main/DirectDriveLEDMatrix
From the video I notice you have no current limiting resistors that page says:-

Note: DON'T FORGET CURRENT-LIMITING RESISTORS.

They won't stop it from working but you could damage the arduino without them.

I noticed that you changed the pin assignment

// your code
int pins[17]= {-1, 18,17,16,15,2,3,4,5,13,12,11,10,9,8,7,6};
// original code 
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};

why is this?

Yes i was using all that whole set of. Res.
I was linking with original code .
And didnt work but yesterday i find code wich is working fine i will post soon

//Ankit Bhatnagar
//5x5 SCROLLING LED MATRIX original code
//24 SEPT 2012
//Font Matrix @ http://arduino.cc/forum/index.php/topic,7384.0.html original code


// i  adapt code to 8x8 matrix just left make the fonts for 8x8
int colA = 13;
int colB = 12;
int colC = 11;
int colD = 10;
int colE = 9;
int colF = 8;
int colG = 7;
int colH = 6;
 
int row1 = 5;
int row2 = 4;
int row3 = 3;
int row4 = 2;
int row5 = 15;
int row6 = 16;
int row7 = 17;
int row8 = 18;
 
int cols[8] = {colA, colB, colC, colD, colE, colF, colG, colH};
int rows[8] = {row1, row2, row3, row4, row5, row6, row7, row8};
 
//character fonts 5X5
byte a[8] = {

B00011000,
B00111100,
B01100110,
B01100110,
B01111110,
B01111110,
B01100110,
B01100110};
byte b[8] = {0x1E, 0x11, 0x1E, 0x11, 0x1E};  
byte c[8] = {0x1E, 0x11, 0x10, 0x11, 0x1E};  
byte d[8] = {0x1E, 0x11, 0x11, 0x11, 0x1E};  
byte e[8] = {0x1F, 0x10, 0x1E, 0x10, 0x1F};
byte f[8] = {0x1F, 0x10, 0x1F, 0x10, 0x10};
byte h[8] = {
B01100110,
B01100110,
B01100110,
B01111110,
B01111110,
B01100110,
B01100110,
B01100110
};
byte i[8] = {0x1F, 0x04, 0x04, 0x04, 0x1F};
byte j[8] = {0x1F, 0x04, 0x04, 0x14, 0x1C};
byte k[8] = {0x11, 0x12, 0x1C, 0x12, 0x11};
byte l[8] = {0x10, 0x10, 0x10, 0x10, 0x1F};
byte m[8] = {0x1B, 0x15, 0x15, 0x11, 0x11};
byte n[8] = {0x11, 0x19, 0x15, 0x13, 0x11};
byte o[8] = {0x0E, 0x11, 0x11, 0x11, 0x0E};
byte p[8] = {0x1F, 0x11, 0x1F, 0x10, 0x10};
byte q[8] = {0x0E, 0x11, 0x15, 0x12, 0x0D};
byte r[8] = {0x1E, 0x11, 0x1E, 0x11, 0x11};
byte s[8] = {0x0F, 0x10, 0x0E, 0x01, 0x1E};
byte t[8] = {0x1F, 0x04, 0x04, 0x04, 0x04};
byte u[8] = {0x11, 0x11, 0x11, 0x11, 0x0E};
byte v[8] = {0x11, 0x11, 0x11, 0x0A, 0x04};
byte y[8] = {0x11, 0x0A, 0x04, 0x04, 0x04};
byte space[8] = {0x00, 0x00, 0x00, 0x00, 0x00};
 
boolean frame_buffer_new[8][8];
boolean string_map[8][8*9];
unsigned long string_map_max_col;
 
unsigned int tcnt2;
unsigned int timer_counter = 0;
unsigned long current_col = 0;
 
void setup()
{
  pinMode(colA, OUTPUT); pinMode(colB, OUTPUT); pinMode(colC, OUTPUT); pinMode(colD, OUTPUT); pinMode(colE, OUTPUT) ; pinMode(colF, OUTPUT); pinMode(colG, OUTPUT); pinMode(colH, OUTPUT);
  pinMode(row1, OUTPUT); pinMode(row2, OUTPUT); pinMode(row3, OUTPUT); pinMode(row4, OUTPUT); pinMode(row5, OUTPUT); pinMode(row6, OUTPUT); pinMode(row7, OUTPUT); pinMode(row8, OUTPUT);
 
  //set timer stuff
  TIMSK2 &= ~(1<<TOIE2);
  TCCR2A &= ~(1<<WGM21) | (1<<WGM20);
  TCCR2B &= ~(1<<WGM22);
  ASSR &= ~(1<<AS2);
  TIMSK2 &= ~(1<<OCIE2A);
  TCCR2B |= (1<<CS22) | (1<<CS20);
  TCCR2B &= ~(1<<CS21);
  tcnt2 = 9;
  TCNT2 = tcnt2;
  TIMSK2 |= (1<<TOIE2);
 
  Serial.begin(9600);
  Serial.println("ISR initialized");
 
  string_map_max_col = 8 * 8;
  create_string_map("testa");
  

  //update frame_buffer_new with first frame
  for(int j=0;j<8;j++)
  {
    frame_buffer_new[0][j] = string_map[0][j];
    frame_buffer_new[1][j] = string_map[1][j];
    frame_buffer_new[2][j] = string_map[2][j];
    frame_buffer_new[3][j] = string_map[3][j];
    frame_buffer_new[4][j] = string_map[4][j];
    frame_buffer_new[5][j] = string_map[5][j];
    frame_buffer_new[6][j] = string_map[6][j];
    frame_buffer_new[7][j] = string_map[7][j];
  }
  display_off();
  Serial.println("String map + first frame created ...");
  //print string_map
  for(int i=0;i<8;i++)
  {
    for(int j=0;j<string_map_max_col;j++)
    {
      Serial.print(string_map[i][j]);
      Serial.print(".");
    }
    Serial.println();
  }
}
 
//install the ISR
ISR(TIMER2_OVF_vect)
{
  timer_counter++;
  if(timer_counter==110) //500 = 1 sec
  {
    //reset timer_counter
    timer_counter=0;
    //disable timer
    TIMSK2 |= (0<<TOIE2);
    //update frame
    Serial.println("Frame update event ...");
    current_col++;
    for(int j=0;j<8;j++)
    {
      frame_buffer_new[0][j] = string_map[0][(current_col+j)%string_map_max_col];
      frame_buffer_new[1][j] = string_map[1][(current_col+j)%string_map_max_col];
      frame_buffer_new[2][j] = string_map[2][(current_col+j)%string_map_max_col];
      frame_buffer_new[3][j] = string_map[3][(current_col+j)%string_map_max_col];
      frame_buffer_new[4][j] = string_map[4][(current_col+j)%string_map_max_col];
      frame_buffer_new[5][j] = string_map[5][(current_col+j)%string_map_max_col];
      frame_buffer_new[6][j] = string_map[6][(current_col+j)%string_map_max_col];
      frame_buffer_new[7][j] = string_map[7][(current_col+j)%string_map_max_col];
    }
    display_and_hold_frame();
    Serial.println(current_col%string_map_max_col);
    /*Serial.println("updated frame buffer");
    for(int i=0;i<5;i++)
    {
      for(int j=0;j<5;j++)
      {
        Serial.print(frame_buffer_new[i][j]);
        Serial.print(".");
      }
      Serial.println();
    }*/
  }
  else
  {
    display_and_hold_frame(); 
  }
  TCNT2 = tcnt2;
  //enable timer
  TIMSK2 |= (1<<TOIE2);
}
 
void loop()
{
  //do nothing .. ISR will take care of it
}
 
void display_off()
{
  for(int i=0;i<8;i++){digitalWrite(rows[i], LOW);digitalWrite(cols[i], HIGH);}
}
 
void display_and_hold_frame()
{
  for(int i=0;i<8;i++){set_col(i);display_off();}
}
 
void set_col(int i)
{
  //set col i to ON => LOW
  digitalWrite(cols[i], LOW);
  if(frame_buffer_new[0][i]) {digitalWrite(rows[0],HIGH);} 
  if(frame_buffer_new[1][i]) {digitalWrite(rows[1],HIGH);} 
  if(frame_buffer_new[2][i]) {digitalWrite(rows[2],HIGH);} 
  if(frame_buffer_new[3][i]) {digitalWrite(rows[3],HIGH);} 
  if(frame_buffer_new[4][i]) {digitalWrite(rows[4],HIGH);}
  if(frame_buffer_new[5][i]) {digitalWrite(rows[5],HIGH);}
  if(frame_buffer_new[6][i]) {digitalWrite(rows[6],HIGH);}
  if(frame_buffer_new[7][i]) {digitalWrite(rows[7],HIGH);}
}
 
void create_string_map(String str)
{
  byte *current_letter;
  int length = str.length();
 
  for(int counter=0;counter<length;counter++)
  {
    switch(str.charAt(counter))
    {
       case 'a': current_letter = a; break; case 'b': current_letter = b; break; 
       case 'c': current_letter = c; break; case 'd': current_letter = d; break; 
       case 'e': current_letter = e; break; case 'f': current_letter = f; break; 
       case 'h': current_letter = h; break; case 'i': current_letter = i; break; 
       case 'j': current_letter = j; break; case 'k': current_letter = k; break;
       case 'l': current_letter = l; break; case 'm': current_letter = m; break; 
       case 'n': current_letter = n; break; case 'o': current_letter = o; break; 
       case 'p': current_letter = p; break; case 'q': current_letter = q; break; 
       case 'r': current_letter = r; break; case 's': current_letter = s; break; 
       case 't': current_letter = t; break; case 'u': current_letter = u; break; 
       case 'v': current_letter = v; break; case 'y': current_letter = y; break; 
    }
 
    for(int j=0;j<8;j++)
    {
      string_map[j][(counter*8)+0] = (current_letter[j]&bit(7))?true:false;
      string_map[j][(counter*8)+1] = (current_letter[j]&bit(6))?true:false;
      string_map[j][(counter*8)+2] = (current_letter[j]&bit(5))?true:false;
      string_map[j][(counter*8)+3] = (current_letter[j]&bit(4))?true:false;
      string_map[j][(counter*8)+4] = (current_letter[j]&bit(3))?true:false;
      string_map[j][(counter*8)+5] = (current_letter[j]&bit(2))?true:false;
      string_map[j][(counter*8)+6] = (current_letter[j]&bit(1))?true:false;
      string_map[j][(counter*8)+7] = (current_letter[j]&bit(0))?true:false;
      string_map[j][(counter*8)+8] = false; //filler column
    }
  }
}

i hope this will be helpfull to someone, i did it

i found this code have some bug if you will place too long massege is getting mestup, im trying to sort this out

if you have any new codes post it please