Home Code DM11A88 8 x 8 LED matrix example

DM11A88 8 x 8 LED matrix example

by shedboy71
[lebox id="1"]
This was an 8×8 dot matrix module which is based on 74hc595, its reasonably easy to program and there is also a tool that allows you to create animations
Description :
Square matrix display module 8×8 dot
Red pixels
Pixel size: 3.0MM
74hc595 driver
Can display variety of patterns and characters

Connection

Arduino Connection Module Connection
5v Vcc
Gnd GND
D11 DI
D12 CLK
D8 LAT

Code

You need an animation header and also a couple of libraries but here is the main code – the zip file underneath has all you need

[codesyntax lang=”cpp”]

#include <TimerOne.h>
#include "animation.h"

//Pin connected to LAT of module
int latchPin = 8;
//Pin connected to CLK of module
int clockPin = 12;
////Pin connected to DI of module
int dataPin = 11;

// A number indicating when to advance to the next frame
unsigned long nextImage = 0;
int animationIndex = 0;
byte brightnesses[64];
int M[8];
//------------------------------------------------------------------------

void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
}

void loop() {
  if(animationIndex >= animationFrames) 
  {
    //restart animation index
    animationIndex = 0;
  }
  else{
    //load Delay time for Image
    nextImage = animationDelays[animationIndex];

    //load image(converted)
    for(int i=0; i<64; i++) {
      brightnesses[i] = (animation[animationIndex][i/4] >> (i%4*2)) & B00000001;
      M[i/8] |= (brightnesses[i] << (i%8)) ;
    }

    //Update Image
    screenUpdate(nextImage);
    animationIndex ++;

    //clear M[]
    for(int i=0; i<(8); ++i) {
      M[i]=0;
    }
  }

}


void screenUpdate(unsigned long frametime) 
{ // function to display image

    unsigned long startime=millis();
  while(millis()-startime<frametime)
  {
    byte row = B10000000; // row 1 
    for (byte k = 0; k < 8; k++) 
    {
      digitalWrite(latchPin, LOW); // open latch ready to receive data
      shiftIt(~row); // row binary number
      shiftIt(M[k]); // LED array (inverted) 

      // Close the latch, sending the data in the registers out to the matrix
      digitalWrite(latchPin, HIGH);
      row = row>> 1; // bitshift right
    }
  } 
}



void shiftIt(byte dataOut) {
  // Shift out 8 bits LSB first, on rising edge of clock
  boolean pinState;

  //clear shift register read for sending data
  digitalWrite(dataPin, LOW);
  // for each bit in dataOut send out a bit
  for (int i=0; i<8; i++) {
    //set clockPin to LOW prior to sending bit
    digitalWrite(clockPin, LOW);
    // if the value of DataOut and (logical AND) a bitmask
    // are true, set pinState to 1 (HIGH)
    if ( dataOut & (1<<i) ) {
      pinState = HIGH;
    }
    else {
      pinState = LOW;
    }
    //sets dataPin to HIGH or LOW depending on pinState
    digitalWrite(dataPin, pinState);
    //send bit out on rising edge of clock
    digitalWrite(clockPin, HIGH);
    digitalWrite(dataPin, LOW);
  }
  digitalWrite(clockPin, LOW); //stop shifting
}

[/codesyntax]

Video

What better way than a video of some of the examples
httpv://www.youtube.com/watch?v=rc8ZWFqNPlQ

Links

I found the resources for this hard to find at first but here is a zip with the code example above, timerone library and also the animation jar file

88 Square Matrix LED

Buy one of them here

Share
[lebox id="2"]

You may also like

Leave a Comment