Max7219 iwht 8x8 matrix, how?


so started project in controll 8x8 led matrix ir sensor, , after research found out led matrix should on chip connects max7219 directly transforming in (i believe) i2c device. have max7219 chip not have chip place matrix , driver. i've seen montage without max 7219 takes waaaaay many pins (12 digital pins , 4 analog) leaving me no space ir sensor. besides, matrix displays nonsense. leave below image.
code: [select]
#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];

// pin[xx] on led matrix connected nn on arduino (-1 dummy make array start @ 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]};

const int numpatterns = 6;
byte patterns[numpatterns][8][8] = {
  h,e,l,l,o,space
};

int pattern = 0;

void setup() {
  // sets pins output
  (int = 1; <= 16; i++) {
    pinmode(pins[i], output);
  }

  // set cols , rows
  (int = 1; <= 8; i++) {
    digitalwrite(cols[i - 1], low);
  }

  (int = 1; <= 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 called
  frequencytimer2::setonoverflow(display);

  setpattern(pattern);
}

void loop() {
    pattern = ++pattern % numpatterns;
    slidepattern(pattern, 60);
}

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

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

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

// interrupt routine
void display() {
  digitalwrite(cols[col], low);  // turn whole previous column off
  col++;
  if (col == 8) {
    col = 0;
  }
  (int row = 0; row < 8; row++) {
    if (leds[col][7 - row] == 1) {
      digitalwrite(rows[row], low);  // turn on led
    }
    else {
      digitalwrite(rows[row], high); // turn off led
    }
  }
  digitalwrite(cols[col], high); // turn whole column on @ once (for equal lighting times)
}


that's code. question is: how can connect max 7219 8x8 led matrix?
thanks in advance



Arduino Forum > Using Arduino > Installation & Troubleshooting > Max7219 iwht 8x8 matrix, how?


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'