'3) Actuator/LED_Dot_Matrix'에 해당되는 글 3건

  1. 2016.09.21 MAX7219 Dot Matrix Module (MAX7219) [D057]
  2. 2016.09.21 8x8 LED dot Matrix (1588AS) [D015]
  3. 2016.09.05 MAX7219 Dot Matrix 4 in One Module (MAX7219) [D080]

MAX7219 Dot Matrix Module (MAX7219) [D057]




https://www.youtube.com/watch?v=cnNFbljvSt0


* Specs

MAX7219 Dot matrix module display module DIY kit SCM control module


* Contents

- Key Code (Ref : https://brainy-bits.com/tutorials/how-to-control-max7219-led-matrix/)

nt dataIn = 12;

int load = 10;

int clock = 11;

 

int maxInUse = 4;    //change this variable to set how many MAX7219's you'll use

 

int e = 0;           // just a variable

 

// define max7219 registers

byte max7219_reg_noop        = 0x00;

byte max7219_reg_digit0      = 0x01;

byte max7219_reg_digit1      = 0x02;

byte max7219_reg_digit2      = 0x03;

byte max7219_reg_digit3      = 0x04;

byte max7219_reg_digit4      = 0x05;

byte max7219_reg_digit5      = 0x06;

byte max7219_reg_digit6      = 0x07;

byte max7219_reg_digit7      = 0x08;

byte max7219_reg_decodeMode  = 0x09;

byte max7219_reg_intensity   = 0x0a;

byte max7219_reg_scanLimit   = 0x0b;

byte max7219_reg_shutdown    = 0x0c;

byte max7219_reg_displayTest = 0x0f;

 

void putByte(byte data) {

  byte i = 8;

  byte mask;

  while(i > 0) {

    mask = 0x01 << (i - 1);      // get bitmask

    digitalWrite( clock, LOW);   // tick

    if (data & mask){            // choose bit

      digitalWrite(dataIn, HIGH);// send 1

    }else{

      digitalWrite(dataIn, LOW); // send 0

    }

    digitalWrite(clock, HIGH);   // tock

    --i;                         // move to lesser bit

  }

}

 

void maxSingle( byte reg, byte col) {    

//maxSingle is the "easy"  function to use for a single max7219

 

  digitalWrite(load, LOW);       // begin    

  putByte(reg);                  // specify register

  putByte(col);//((data & 0x01) * 256) + data >> 1); // put data  

  digitalWrite(load, LOW);       // and load da stuff

  digitalWrite(load,HIGH);

}

 

void maxAll (byte reg, byte col) {    // initialize  all  MAX7219's in the system

  int c = 0;

  digitalWrite(load, LOW);  // begin    

  for ( c =1; c<= maxInUse; c++) {

  putByte(reg);  // specify register

  putByte(col);//((data & 0x01) * 256) + data >> 1); // put data

    }

  digitalWrite(load, LOW);

  digitalWrite(load,HIGH);

}

 

void maxOne(byte maxNr, byte reg, byte col) {    

//maxOne is for addressing different MAX7219's,

//while having a couple of them cascaded

 

  int c = 0;

  digitalWrite(load, LOW);  // begin    

 

  for ( c = maxInUse; c > maxNr; c--) {

    putByte(0);    // means no operation

    putByte(0);    // means no operation

  }

 

  putByte(reg);  // specify register

  putByte(col);//((data & 0x01) * 256) + data >> 1); // put data

 

  for ( c =maxNr-1; c >= 1; c--) {

    putByte(0);    // means no operation

    putByte(0);    // means no operation

  }

 

  digitalWrite(load, LOW); // and load da stuff

  digitalWrite(load,HIGH);

}

 

 

void setup () {

 

  pinMode(dataIn, OUTPUT);

  pinMode(clock,  OUTPUT);

  pinMode(load,   OUTPUT);

 

  digitalWrite(13, HIGH);  

 

//initiation of the max 7219

  maxAll(max7219_reg_scanLimit, 0x07);      

  maxAll(max7219_reg_decodeMode, 0x00);  // using an led matrix (not digits)

  maxAll(max7219_reg_shutdown, 0x01);    // not in shutdown mode

  maxAll(max7219_reg_displayTest, 0x00); // no display test

   for (e=1; e<=8; e++) {    // empty registers, turn all LEDs off

    maxAll(e,0);

  }

  maxAll(max7219_reg_intensity, 0x0f & 0x0f);    // the first 0x0f is the value you can set

                                                  // range: 0x00 to 0x0f

}  

 

void loop () {

 

  //if you use just one MAX7219 it should look like this

   maxSingle(1,1);                       //  + - - - - - - -

   maxSingle(2,2);                       //  - + - - - - - -

   maxSingle(3,4);                       //  - - + - - - - -

   maxSingle(4,8);                       //  - - - + - - - -

   maxSingle(5,16);                      //  - - - - + - - -

   maxSingle(6,32);                      //  - - - - - + - -

   maxSingle(7,64);                      //  - - - - - - + -

   maxSingle(8,128);                     //  - - - - - - - +

 

 delay(2000);

 

 //if you use more than one MAX7219, it should look like this

  

  maxAll(1,1);                       //  + - - - - - - -

  maxAll(2,3);                       //  + + - - - - - -

  maxAll(3,7);                       //  + + + - - - - -

  maxAll(4,15);                      //  + + + + - - - -

  maxAll(5,31);                      //  + + + + + - - -

  maxAll(6,63);                      //  + + + + + + - -

  maxAll(7,127);                     //  + + + + + + + -

  maxAll(8,255);                     //  + + + + + + + +

  

 delay(2000);

 

  //if you use more than one max7219 the second one should look like this

  /*

  maxOne(2,1,1);                       //  + - - - - - - -

  maxOne(2,2,2);                       //  - + - - - - - -

  maxOne(2,3,4);                       //  - - + - - - - -

  maxOne(2,4,8);                       //  - - - + - - - -

  maxOne(2,5,16);                      //  - - - - + - - -

  maxOne(2,6,32);                      //  - - - - - + - -

  maxOne(2,7,64);                      //  - - - - - - + -

  maxOne(2,8,128);                     //  - - - - - - - +

  */

 

  delay(2000);

 

}

Posted by RD IoT RDIoT

댓글을 달아 주세요

8x8 LED dot Matrix (1588AS) [D015]



https://www.youtube.com/watch?v=og9wftJlcR0


* Specs

ED DOT MATRIX 8X8 HS-1588AB (RED)


* Contents

- Connect

1 - R220 - D13

2 - R220 - D12

3 - R220 - D11

4 - R220 - D10

5 - R220 - A2

6 - R220 - A3

7 - R220 - A4

8 - R220 - A5

 

9 - D2

10 - D3

11 - D4

12 - D5

13 - D6

14 - D7

15 - D8

16 - D9 


- Ref Source

http://arduino-er.blogspot.kr/2014/08/walking-bit-on-88-led-matrix-with.html


- Key Code

// 2-dimensional array of row pin numbers:

const int row[8] = {

  2, 7, 19, 5, 13, 18, 12, 16

};

 

// 2-dimensional array of column pin numbers:

const int col[8] = {

  6, 11, 10, 3, 17, 4, 8, 9

};

 

// 2-dimensional array of pixels:

int pixels[8][8];

 

int posX = 7;

int posY = 7;

int count = 30;

bool bg = false;

 

void setup() {

  // initialize the I/O pins as outputs

  // iterate over the pins:

  for (int thisPin = 0; thisPin < 8; thisPin++) {

    // initialize the output pins:

    pinMode(col[thisPin], OUTPUT);

    pinMode(row[thisPin], OUTPUT);

    // take the col pins (i.e. the cathodes) high to ensure that

    // the LEDS are off:

    digitalWrite(col[thisPin], HIGH);

  }

 

  setupScreen();

 

}

 

void loop() {

 

  // draw the screen:

  refreshScreen();

  

  if(count-- == 0){

    count = 500;

    if(posX--==0){

      posX = 7;

      if(posY--==0){

        posY = 7;

        bg = !bg;

      }

    }

    setupScreen();

 

  }

}

 

void setupScreen(){

  if(bg){

    //ON all others

    for (int x = 0; x < 8; x++) {

      for (int y = 0; y < 8; y++) {

        pixels[x][y] = LOW;

      }

    }

    

    //OFF current pos

    pixels[posX][posY] = HIGH;

  }else{

    //OFF all others

    for (int x = 0; x < 8; x++) {

      for (int y = 0; y < 8; y++) {

        pixels[x][y] = HIGH;

      }

    }

    

    //ON current pos

    pixels[posX][posY] = LOW;

  }

}

 

void refreshScreen() {

  // iterate over the rows (anodes):

  for (int thisRow = 0; thisRow < 8; thisRow++) {

    // take the row pin (anode) high:

    digitalWrite(row[thisRow], HIGH);

    // iterate over the cols (cathodes):

    for (int thisCol = 0; thisCol < 8; thisCol++) {

      // get the state of the current pixel;

      int thisPixel = pixels[thisRow][thisCol];

      // when the row is HIGH and the col is LOW,

      // the LED where they meet turns on:

      digitalWrite(col[thisCol], thisPixel);

      // turn the pixel off:

      if (thisPixel == LOW) {

        digitalWrite(col[thisCol], HIGH);

      }

    }

    // take the row pin low to turn off the whole row:

    digitalWrite(row[thisRow], LOW);

  }

}

Posted by RD IoT RDIoT

댓글을 달아 주세요

MAX7219 Dot Matrix 4 in One Module (MAX7219) [D080]




https://www.youtube.com/watch?v=HQFkxxBsr1Y


* Specs

Using a LED Dot Matrix in your next project can be a way to incorporate some cool little animations.

By using these 8X8 matrix modules you can  create your own.

Since these modules use the MAX7219 LED driver chip, we will be able to turn on and off the 64 LEDs of each modules, using only 3 pins on our Arduino.


* Content

- Connect

VCC - 5V

GND - GND

DIN - D12

CS - D10

CLK - D11


- Library : https://brainy-bits.com/wp-content/uploads/2015/01/LedControl.zip

- Sketch : https://brainy-bits.com/wp-content/uploads/2015/01/MAX7219_Tutorial.zip


- Key Code

#include "LedControl.h"

LedControl lc=LedControl(12,11,10,2);  // Pins: DIN,CLK,CS, # of Display connected


unsigned long delayTime=500;


// Put values in arrays

byte invader1a[] =

{

   B00011000,  // First frame of invader #1

   B00111100,

   B01111110,

   B11011011,

   B11111111,

   B00100100,

   B01011010,

   B10100101

};



void setup()

{

  lc.shutdown(0,false);  // Wake up displays

  lc.shutdown(1,false);

  lc.setIntensity(0,5);  // Set intensity levels

  lc.setIntensity(1,5);

  lc.clearDisplay(0);  // Clear Displays

  lc.clearDisplay(1);

}



Posted by RD IoT RDIoT

댓글을 달아 주세요