Go Down

Topic: Need help changing code to change display orientation (Read 3491 times) previous topic - next topic

spongeman619

Hello

I am programming a 5x7 LED matrix. I found this code

http://mvartan.com/2013/03/08/arduino-5x7-matrix-display-controller-hdsp-4403/

the problem is the orientation of the display in the code. I'm trying to figure how to make the letters go this way
          7
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 5 <direction of letters >
0 0 0 0 0 0 0
0 0 0 0 0 0 0

instead of this way

         5
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0   7 <direction of letters >
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

what happens when I upload the code is the display starts the letters on the left side like this 'A" for example

          7
1  1 0 0 0  1  1
0 1 0 0 0 1 0
1  1 0 0 0 1  1 5 <direction of letters >
0 1 0 0 0 1 0
0 1 0 0 0 1 0

you'll notice how the display restarts at the fifth row. Also the letter is going below the display. from this I know that the orientation is the wrong way. the code makes it 7x5 instead of 5x7.

any help would be appreciated

thanks

HazardsMind

Post your code. You can make a function that rotates the bytes 90* before showing them. I made a function that does just that but it is made to work with 8x8 displays. I don't think it will work on a 5x7.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

spongeman619

I have linked the code above

you can also find it here

http://mvartan.com/2013/03/08/arduino-5x7-matrix-display-controller-hdsp-4403/

HazardsMind

#3
Apr 18, 2014, 11:32 pm Last Edit: Apr 18, 2014, 11:46 pm by HazardsMind Reason: 1
There is a way to do it, but that would require rewriting the code.

Here is my function, if your interested.
Code: [Select]
byte* rotate90deg(byte data[]){ //private func
  Serial.println();
  for(int c=0;c<8;c++)
  {
    for(int r=0;r<8;r++)
    {
      tmpAry[r] <<= 1;
      tmpAry[r] |= bitRead(data[c],r);
      //Serial.println(tmpAry[r],BIN);
    }
    //Serial.println();
  }
  return tmpAry;
}


I don't have a 5*7 display to do any tests, so I can only go by the serial monitor. Sorry.

This is my method to rotate the array 0, 90, 180 and 270 degrees.
Code: [Select]
byte flip(byte ary)//private func
{
  static const byte table[16] = {
    0x0, 0x8, 0x4, 0xC,
    0x2, 0xA, 0x6, 0xE,
    0x1, 0x9, 0x5, 0xD,
    0x3, 0xB, 0x7, 0xF
  };
  byte h = table[(ary & 0xf0) >> 4];
  //Serial.println(h,HEX);
  byte l = table[ary & 0x0f] << 4;
  //Serial.println(l,HEX);
  return (l | h );
}

byte RotateData(byte data[], int rot){
  int cnt=0;
  //Serial.println(data,HEX);
  switch(rot)
  {
  case 0:
    display(data,0);
    break;

  case 90:
    display(rotate90deg(data),0); // 90
    break;

  case 180:
    display(data,1); // 180
    break;

  case 270:
    display(rotate90deg(data),1); // 270
    break;
  }
}

void display(byte *Ary, boolean Inv){
  for(byte k = 0; k < 8; k++)
  {
    if(Inv)
    {
      shiftOut(data,clock,MSBFIRST,8-k);
      shiftOut(data,clock,MSBFIRST, flip(Ary[k]));
    }
    else
    {
      shiftOut(data,clock,MSBFIRST,k+(byte)1);
      shiftOut(data,clock,MSBFIRST, Ary[k]); 
    }
    digitalWrite(load,LOW);
    digitalWrite(load,HIGH);
  }
  Serial.println();
}
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

spongeman619

I found code online for my 5x7 display but the letters are going the wrong way for example in this video that was on the same page as the code the display is vertical and the letters are going horizontally.

https://www.youtube.com/watch?v=ac0dfPB-oiM

My display is vertical like the on in the video but my text is also scrolling vertically. Also the first 2 rows are always on .

here is the original code

Code: [Select]
#include <TimerOne.h>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#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} \
}

#define DOT { \
  {0,0,0,0,0,0,0}, \
  {0,1,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 COLS 5
#define ROWS 7
#define PINS 13

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

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

byte col = 0;
byte leds[COLS][ROWS];

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

// col[xx] of leds = pin yy on led matrix
int cols[COLS] = {pins[1], pins[3], pins[10], pins[7], pins[8]};

// row[xx] of leds = pin yy on led matrix
int rows[ROWS] = {pins[12], pins[11], pins[2], pins[9], pins[4], pins[5], pins[6]};

const int numPatterns = 7;
byte patterns[numPatterns][COLS][ROWS] = {MATRIX2, S, T, E, A, K, MATRIX1};

int pattern = 0;

void setup() {
 
  //Serial.begin(9600);
 
  // sets the pins as output
  for (int i = 0; i < PINS; i++) {
    pinMode(pins[i], OUTPUT);
  }

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

 
  clearLeds();

  Timer1.initialize(2000);         // initialize timer1, and set a 1/2 second period
  Timer1.attachInterrupt(display);  // attaches display() as a timer overflow interrupt

  setPattern(pattern);
}

void loop() {
pattern = ++pattern % numPatterns;
slidePattern(pattern, 180);
}
// Interrupt routine
void display() {
  digitalWrite(cols[col], 0);  // Turn whole previous column off
  col++;
  if (col == 5) {
    col = 0;
  }
  for (int row = 0; row < 7; row++) {
    if (leds[col][(ROWS - 1) - row] == 1) {
      digitalWrite(rows[row], 0);  // Turn on this led
    }
    else {
      digitalWrite(rows[row], 1); // Turn off this led
    }
   // delay(10);
  }
  digitalWrite(cols[col], 1); // Turn whole column on at once (for equal lighting times)

}

void slidePattern(int pattern, int del) {
  for (int l = 0; l < COLS; l++) {
    for (int i = 0; i < (COLS - 1); i++) {
      for (int j = 0; j < ROWS; j++) {
        leds[i][j] = leds[i + 1][j];
      }
    }
    for (int j = 0; j < ROWS; j++) {
      leds[4][j] = patterns[pattern][0 + l][j];
    }
    delay(del);
  }
}

void clearLeds() {
  // Clear display array
  for (int i = 0; i < COLS; i++) {
    for (int j = 0; j < ROWS; j++) {
      leds[i][j] = 0;
    }
  }
}
 
void setPattern(int pattern) {
  for (int i = 0; i < COLS; i++) {
    for (int j = 0; j < ROWS; j++) {
      leds[i][j] = patterns[pattern][i][j];
    }
  }
}


any help would be appreciated

thanks

spongeman619

I found code online for my 5x7 display but the letters are going the wrong way for example in this video that was on the same page as the code the display is vertical and the letters are going horizontally.

https://www.youtube.com/watch?v=ac0dfPB-oiM

My display is vertical like the on in the video but my text is also scrolling vertically. Also the first 2 rows are always on .

here is the original code

Code: [Select]
#include <TimerOne.h>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#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} \
}

#define DOT { \
  {0,0,0,0,0,0,0}, \
  {0,1,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 COLS 5
#define ROWS 7
#define PINS 13

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

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

byte col = 0;
byte leds[COLS][ROWS];

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

// col[xx] of leds = pin yy on led matrix
int cols[COLS] = {pins[1], pins[3], pins[10], pins[7], pins[8]};

// row[xx] of leds = pin yy on led matrix
int rows[ROWS] = {pins[12], pins[11], pins[2], pins[9], pins[4], pins[5], pins[6]};

const int numPatterns = 7;
byte patterns[numPatterns][COLS][ROWS] = {MATRIX2, S, T, E, A, K, MATRIX1};

int pattern = 0;

void setup() {
 
  //Serial.begin(9600);
 
  // sets the pins as output
  for (int i = 0; i < PINS; i++) {
    pinMode(pins[i], OUTPUT);
  }

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

 
  clearLeds();

  Timer1.initialize(2000);         // initialize timer1, and set a 1/2 second period
  Timer1.attachInterrupt(display);  // attaches display() as a timer overflow interrupt

  setPattern(pattern);
}

void loop() {
pattern = ++pattern % numPatterns;
slidePattern(pattern, 180);
}
// Interrupt routine
void display() {
  digitalWrite(cols[col], 0);  // Turn whole previous column off
  col++;
  if (col == 5) {
    col = 0;
  }
  for (int row = 0; row < 7; row++) {
    if (leds[col][(ROWS - 1) - row] == 1) {
      digitalWrite(rows[row], 0);  // Turn on this led
    }
    else {
      digitalWrite(rows[row], 1); // Turn off this led
    }
   // delay(10);
  }
  digitalWrite(cols[col], 1); // Turn whole column on at once (for equal lighting times)

}

void slidePattern(int pattern, int del) {
  for (int l = 0; l < COLS; l++) {
    for (int i = 0; i < (COLS - 1); i++) {
      for (int j = 0; j < ROWS; j++) {
        leds[i][j] = leds[i + 1][j];
      }
    }
    for (int j = 0; j < ROWS; j++) {
      leds[4][j] = patterns[pattern][0 + l][j];
    }
    delay(del);
  }
}

void clearLeds() {
  // Clear display array
  for (int i = 0; i < COLS; i++) {
    for (int j = 0; j < ROWS; j++) {
      leds[i][j] = 0;
    }
  }
}
 
void setPattern(int pattern) {
  for (int i = 0; i < COLS; i++) {
    for (int j = 0; j < ROWS; j++) {
      leds[i][j] = patterns[pattern][i][j];
    }
  }
}


any help would be appreciated

thanks

HazardsMind

#6
Apr 22, 2014, 12:47 am Last Edit: Apr 22, 2014, 12:49 am by HazardsMind Reason: 1
Try this function. I don't have a 5x7 display, so I used the serial monitor. ALSO, you will need to fix your letter arrays. You must make all the letter be centered in the array.

Letters that are NOT centered and must be fixed.
A, E, F, H, I, K, L, O, R, S, T, V

Code: [Select]

[b]// Put this in setup() function.[/b]
for(byte p = 0; p < 5; p++)
  RotatePattern(2);

. . .

[b]//Put this at the bottom of sketch.[/b]
void RotatePattern(int pattern)  // This function will rotate everything in the center of the 5x7 letter arrays, within your pattern.
{
  for (int i = 0; i < 5; i++) //col
  {
    for (int j = 1; j < 6; j++) //row You want to be in a 5x5 box,
    {
      //Serial.print(patterns[pattern][i][j]);
      leds[5-j][i] = patterns[pattern][i][j]; // this will rotate the letter.
    }
    //Serial.println();
  }
//  Serial.println();
//   for (int i = 0; i < 5; i++) //col
//  {
//    for (int j = 1; j < 6; j++) //row
//    {
//      Serial.print(leds[i][j]);
//    }
//    Serial.println();
//  }
}
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

spongeman619

#7
Apr 22, 2014, 01:05 am Last Edit: Apr 22, 2014, 01:10 am by spongeman619 Reason: 1
Thanks for replying

I used your function as you stated in the comments next to the code, but it has made no difference. the letters are still going the wrong way and the 6th and 7th rows are still on all the time. heres the new code with your function added in.

Also the reason that those letters are not centered is because that is they only way they are legible. if I center them the top will be cut off.

Im using the TC07-11EWA display

http://www.mouser.com/ds/2/216/TC07-11EWA-83196.pdf

Code: [Select]
#include <TimerOne.h>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#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} \
}

#define DOT { \
 {0,0,0,0,0,0,0}, \
 {0,1,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 COLS 5
#define ROWS 7
#define PINS 13

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

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

byte col = 0;
byte leds[COLS][ROWS];

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

// col[xx] of leds = pin yy on led matrix
int cols[COLS] = {pins[1], pins[3], pins[10], pins[7], pins[8]};

// row[xx] of leds = pin yy on led matrix
int rows[ROWS] = {pins[12], pins[11], pins[2], pins[9], pins[4], pins[5], pins[6]};

const int numPatterns = 7;
byte patterns[numPatterns][COLS][ROWS] = {MATRIX2, S, T, E, A, K, MATRIX1};

int pattern = 0;

void setup() {
 
 for(byte p = 0; p < 5; p++)
 RotatePattern(2);
 
 Serial.begin(9600);
 
 // sets the pins as output
 for (int i = 0; i < PINS; i++) {
   pinMode(pins[i], OUTPUT);
 }

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

 
 clearLeds();

 Timer1.initialize(2000);         // initialize timer1, and set a 1/2 second period
 Timer1.attachInterrupt(display);  // attaches display() as a timer overflow interrupt

 setPattern(pattern);
}

void loop() {
pattern = ++pattern % numPatterns;
slidePattern(pattern, 180);
}
// Interrupt routine
void display() {
 digitalWrite(cols[col], 0);  // Turn whole previous column off
 col++;
 if (col == 5) {
   col = 0;
 }
 for (int row = 0; row < 7; row++) {
   if (leds[col][(ROWS - 1) - row] == 1) {
     digitalWrite(rows[row], 0);  // Turn on this led
   }
   else {
     digitalWrite(rows[row], 1); // Turn off this led
   }
  // delay(10);
 }
 digitalWrite(cols[col], 1); // Turn whole column on at once (for equal lighting times)

}

void slidePattern(int pattern, int del) {
 for (int l = 0; l < COLS; l++) {
   for (int i = 0; i < (COLS - 1); i++) {
     for (int j = 0; j < ROWS; j++) {
       leds[i][j] = leds[i + 1][j];
     }
   }
   for (int j = 0; j < ROWS; j++) {
     leds[4][j] = patterns[pattern][0 + l][j];
   }
   delay(del);
 }
}

void clearLeds() {
 // Clear display array
 for (int i = 0; i < COLS; i++) {
   for (int j = 0; j < ROWS; j++) {
     leds[i][j] = 0;
   }
 }
}
 
void setPattern(int pattern) {
 for (int i = 0; i < COLS; i++) {
   for (int j = 0; j < ROWS; j++) {
     leds[i][j] = patterns[pattern][i][j];
   }
 }
}

void RotatePattern(int pattern)  // This function will rotate everything in the center of the 5x7 letter arrays, within your pattern.
{
 for (int i = 0; i < 5; i++) //col
 {
   for (int j = 1; j < 6; j++) //row You want to be in a 5x5 box,
   {
     Serial.print(patterns[pattern][i][j]);
     leds[5-j][i] = patterns[pattern][i][j]; // this will rotate the letter.
   }
   Serial.println();
 }
}

HazardsMind

#8
Apr 22, 2014, 01:25 am Last Edit: Apr 22, 2014, 01:29 am by HazardsMind Reason: 1
In my function, in your setup(), change the 2 to p, and add a delay time.

Quote
I used your function as you stated in the comments next to the code, but it has made no difference. the letters are still going the wrong way and the 6th and 7th rows are still on all the time. heres the new code with your function added in.

It might be doing what you want, but I didn't add a delay, so change the function to this.
Code: [Select]
void RotatePattern(int pattern, int del)
{
 for (int i = 0; i < 5; i++) //col
 {
   for (int j = 1; j < 6; j++) //row You want to be in a 5x5 box,
   {
     leds[5-j][i] = patterns[pattern][i][j]; // this will rotate the letter.
     //Serial.print(patterns[pattern][i][j]);
   }
   //Serial.println();
   delay(del);
 }
}


You also need to comment out this line "setPattern(pattern);" and move what I gave you after it.

Quote

Also the reason that those letters are not centered is because that is they only way they are legible. if I center them the top will be cut off.

That doesn't sound good to me. If your telling it to show something in a 5x7 grid, then you should see everything and not have anything cut off.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

spongeman619

still not working after doing everything you said except

Quote
move what I gave you after it.


not sure what that means

so far there have been no changes except a small delay at the very start.

Im starting to think that my display might be 7x5, maybe there is some way to change the code to fit a 7x5 display?

thanks for all you help so far

HazardsMind

Ok the only other thing I can think of, is this. Open a new sketch and copy & paste the whole thing.
Code: [Select]
#include <TimerOne.h>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#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} \
}

#define DOT { \
  {0,0,0,0,0,0,0}, \
  {0,1,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 COLS 5
#define ROWS 7
#define PINS 13

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

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

byte col = 0;
byte leds[COLS][ROWS];

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

// col[xx] of leds = pin yy on led matrix
int cols[COLS] = {pins[1], pins[3], pins[10], pins[7], pins[8]};

// row[xx] of leds = pin yy on led matrix
int rows[ROWS] = {pins[12], pins[11], pins[2], pins[9], pins[4], pins[5], pins[6]};

const int numPatterns = 7;
byte patterns[numPatterns][COLS][ROWS] = {MATRIX2, S, C, E, A, K, MATRIX1};

int pattern = 0;

void setup() {
 
  Serial.begin(115200);
 
  // sets the pins as output
  for (int i = 0; i < PINS; i++)
  {
    pinMode(pins[i], OUTPUT);
  }

  // set up cols
  for (int i = 1; i <= COLS; i++)
  {
    digitalWrite(cols[i - 1], 0);
  }
  //  and rows
  for (int i = 1; i <= ROWS; i++)
  {
    digitalWrite(rows[i - 1], 1);
  }
 
  clearLeds();

  Timer1.initialize(2000);         // initialize timer1, and set a 1/2 second period
  Timer1.attachInterrupt(display);  // attaches display() as a timer overflow interrupt

  //setPattern(pattern);
}

void loop() {
pattern = ++pattern % numPatterns;
//slidePattern(pattern, 180);
RotatePattern(pattern);
}

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

void slidePattern(int pattern, int del)
{
  for (int l = 0; l < COLS; l++)
  {
    for (int i = 0; i < (COLS - 1); i++)
    {
      for (int j = 0; j < ROWS; j++)
      {
        leds[i][j] = leds[i + 1][j];
      }
    }
    for (int j = 0; j < ROWS; j++)
    {
      leds[4][j] = patterns[pattern][0 + l][j];
    }
    delay(del);
  }
}

void clearLeds()
{
  // Clear display array
  for (int i = 0; i < COLS; i++)
  {
    for (int j = 0; j < ROWS; j++)
    {
      leds[i][j] = 0;
    }
  }
}
 
void setPattern(int pattern)
{
  for (int i = 0; i < COLS; i++)
  {
    for (int j = 0; j < ROWS; j++)
    {
      leds[i][j] = patterns[pattern][i][j];
    }
  }
}

void RotatePattern(int pattern)
{
  for (int i = 0; i < 5; i++) //col
  {
    for (int j = 1; j < 6; j++) //row You want to be in a 5x5 box,
    {
      leds[5-j][i] = patterns[pattern][i][j]; // this will rotate the letter.
      //Serial.print(patterns[pattern][i][j]);
    }
    //Serial.println();
  }
}
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

tsunamy_boy

You have to reconnect all the LED's because you did it wrong!


spongeman619

Well it still didn't work

Thanks for everything

tsunamy_boy

#14
Apr 22, 2014, 02:32 am Last Edit: Apr 22, 2014, 02:38 am by tsunamy_boy Reason: 1

how do you know?


because there are 2 rows not working, which tells me that you are drawing it in the wrong way.
Take a look 2 rows missing it's because you are drawing the 7x5 instead of drawing 5x7. 5+2 = 7.

Go Up