LED Matrix Display 64x16

Hello everybody. I recently bought a led matrix 64x16:

http://www.canton-electronics.com/arduino-starter-kit-c-100/lcdled-display-c-100_101/provide-arduino-code-64x16-dot-matrix-led-for-diy-sign-light-neon-bright-uno-mcu-p-628.html

The arduino sketch provided works fine. Now I want to adjust the code to display another text.

This is the code:

//Author: cantone-electonics
//More information welcome to : http://www.canton-electronics.com 
//Arduino 1.0.4
//Arduino uno R3
//64x16 Matrix LED

#define COL_PIXEL     64
#define ROW_PIXEL     16

int latchPin=8; //LT
int clockPin=12;//SK
int dataPin=11; //R1

int en_74138 = 2;
int la_74138 = 3;
int lb_74138 = 4;
int lc_74138 = 5;
int ld_74138 = 6;
 
unsigned int ROW_xPixel;
unsigned int ROW_num;
unsigned char Col_num_1;
unsigned char Col_num_2;
unsigned char Col_num_3;
unsigned char Col_num_4;
unsigned char Col_num_5;
unsigned char Col_num_6;
unsigned char Col_num_7;
unsigned char Col_num_8;


//Data code: Horizontal modulus ,Bytes reverse order
unsigned char  Bmp1[]=
{
/*------------------------------------------------------------------------------
;  Width X height (pixels): 64X16
;I Love You
------------------------------------------------------------------------------*/
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0, 0xff, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xc0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xc, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x3, 0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x3, 0xc0, 0x3, 0x3, 0x30, 0xf0, 0x0, 0xc0, 0xc, 
0xf0, 0xc0, 0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 0x30, 0xc, 0x3, 0x30, 0xc, 0x3, 0x0, 0x3, 0xc, 0xc3, 0x0, 0x3, 0x0, 0xc,
0x0, 0x3, 0xc, 0x30, 0x3, 0x30, 0x3, 0xc, 0x0, 0x3, 0x3, 0xcc, 0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 0xc, 0x30, 0x3, 0x30,
0x3, 0xc, 0x0, 0x3, 0x3, 0xcc, 0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 0xc, 0x30, 0x3, 0x30, 0xf, 0xc, 0x0, 0x3, 0x3, 0xcc, 
0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 0xc, 0x30, 0x3, 0x30, 0xf3, 0x3, 0x0, 0x3, 0x3, 0xcc, 0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 
0xc, 0x30, 0xc, 0xc, 0x3, 0x0, 0x0, 0x3, 0x3, 0xcc, 0x0, 0x3, 0x0, 0xc, 0x0, 0xc3, 0x30, 0xc, 0x30, 0x3, 0x3, 0xc, 
0x0, 0x3, 0xc, 0xc3, 0x0, 0x3, 0xc0, 0xff, 0x0, 0xff, 0xc0, 0x3, 0xc0, 0x0, 0xfc, 0x3, 0x0, 0x3, 0xf0, 0x0, 0xff, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 
};



unsigned char  Bmp2[]=
{
/*------------------------------------------------------------------------------
; Width X height (pixels): 16X16
;WELCOME 64 16
------------------------------------------------------------------------------*/
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x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0xf, 0x0, 0xf, 0xf0, 0x3c, 0xf, 0xcf, 0x3, 0x0, 0xc0, 0xcf, 0xf, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0x3f, 0xfc, 0x3f, 
0x3c, 0xc, 0xcf, 0xff, 0x3f, 0x0, 0x3, 0x3, 0xfc, 0xff, 0xfc, 0xff, 0xf0, 0x3f, 0xf0, 0xf, 0x3c, 0xc, 0xcf, 0xff, 0x3f, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
};


void shiftOut(unsigned char dataOut)
{
  
    for(int i=0;i<=7;i++)
   {
      PORTB &=~(1<<(clockPin-8));//equate digitalWrite(clockPin,LOW);
       
     if(dataOut & (0x01<<i))  PORTB |=1<<(dataPin-8); //equate digitalWrite(dataPin,HIGH);
     else  PORTB &=~(1<<(dataPin-8));//equate digitalWrite(dataPin,LOW);
     
     PORTB |=1<<(clockPin-8);//equate digitalWrite(clockPin,HIGH);
     
   }
}

//Combine 2 bits/pixel to 1 bits/pixel 
unsigned char Combine_2BitsTo1Bit(unsigned char num,unsigned char *BMP)
{
  
  unsigned char Col_num_tem_1;
  unsigned char Col_num_tem_2;
  unsigned int Col_num_tem = 0;
  unsigned char i=0;
  unsigned char Col_num_1bit = 0x00;
  
  Col_num_tem_1 = *(BMP+num);
  Col_num_tem_2 = *(BMP+num+1);
  
  Col_num_tem = Col_num_tem_1;
  Col_num_tem |= (Col_num_tem_2 << 8);
  
 for(i=0;i<8;i++)
  {   
    if(Col_num_tem&(0x0003<<i*2)) Col_num_1bit |= (0x01<<i);
  }
  return ~Col_num_1bit;
}

//display one picture 
void display_martix(unsigned char *BMP)
{
  //Display count
  unsigned int dis_cnt=256;
  unsigned int i;
  
   for(i=0;i<dis_cnt*16;i++)
   {
     
     digitalWrite(en_74138, HIGH);//Turn off display
  
     //Col scanning
    shiftOut(Col_num_1);
    shiftOut(Col_num_2);
    shiftOut(Col_num_3);
    shiftOut(Col_num_4);
    shiftOut(Col_num_5);
    shiftOut(Col_num_6);
    shiftOut(Col_num_7);
    shiftOut(Col_num_8);
  
    digitalWrite(latchPin, LOW);
    digitalWrite(latchPin, HIGH);
  
    //Row scanning
    // AVR Port Operation 
    PORTD = ((ROW_xPixel << 3 ) & 0X78) | (PORTD & 0X87);//Write PIN 3 4 5 6 la_74138 lb_74138 lc_74138 ld_74138
     
    digitalWrite(en_74138, LOW);//Turn on display
  

     
    if(ROW_xPixel==15) ROW_xPixel=0; else ROW_xPixel++;
  
   /*
   // Single color,1 bits/pixel
   Col_num_1=~BMP[(COL_PIXEL/8)*ROW_xPixel];
   Col_num_2=~BMP[(COL_PIXEL/8)*ROW_xPixel+1];
   Col_num_3=~BMP[(COL_PIXEL/8)*ROW_xPixel+2];
   Col_num_4=~BMP[(COL_PIXEL/8)*ROW_xPixel+3];
   Col_num_5=~BMP[(COL_PIXEL/8)*ROW_xPixel+4];
   Col_num_6=~BMP[(COL_PIXEL/8)*ROW_xPixel+5];
   Col_num_7=~BMP[(COL_PIXEL/8)*ROW_xPixel+6];
   Col_num_8=~BMP[(COL_PIXEL/8)*ROW_xPixel+7];
 */
   
   //Single color,2 bits/pixel 
   Col_num_1 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2,BMP);
   Col_num_2 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+2,BMP);
   Col_num_3 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+4,BMP);
   Col_num_4 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+6,BMP);
   Col_num_5 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+8,BMP);
   Col_num_6 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+10,BMP);
   Col_num_7 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+12,BMP);
   Col_num_8 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+14,BMP);
  
  // delayMicroseconds(1000); 
   
  }
  
}

void setup()
{
  pinMode(latchPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(dataPin,OUTPUT);
  
  pinMode(en_74138,OUTPUT);
  pinMode(la_74138,OUTPUT);
  pinMode(lb_74138,OUTPUT);
  pinMode(lc_74138,OUTPUT);
  pinMode(ld_74138,OUTPUT);
  
  
  digitalWrite(en_74138, LOW);
  
  // AVR Port Settings
  DDRD |= 0x78; //Set PIN 3 4 5 6 output  
  
  
  
  
}




void loop()
{

  
 display_martix(Bmp1);

 display_martix(Bmp2);
}

I would like to alter the text, but I don't understand how to do that. The code for the text is in HEX, I can imagine the first line is blanc becourse HEX0X0 = 0000. Then I cant figure out how it works. Is the re someone who van point me in the right direction.

Greets Herman

it is not a text, in just a static BMP image

I think this is rather crude code. Encoding strings as static images is quite inconvenient.
Look at the Parola library, it can display text on similar displays using different fonts

Thnx for the reaction.

The intention was to display a logo on the Matrix display. I thought by adjusting the hex code I could get this done. Apparently that is not possible.
Is it possible to create a logo with 64x16 pixels and transfer it to hex?

in order to be able to display custom patterns one needs to know how modules are connected, which one is first, which one is last, at least, because mcu pushes data through all modules until it reaches the last one. Try library or study the code

I doubt that very much. But you have to spend time on it :wink:

If I wanted to figure it out

  1. fill a bitmap array with 0x00; what does it do?
  2. fill a bitmap array with 0xFF; what does it do?
  3. fill a bitmap array with 0x3C; what does it do?
  4. fill a bitmap array with 0xF0; what does it do?

Once I've figured out the above, fill the bitmap array with 0x00; change one array element to e.g. 0xFF and see which LED changes. Repeat for another array element.

Notes:

  1. The hex values above were picked from Bmp2.
  2. From the page that you linked "With the display you get full documentantion and example sketch by email!". I have no idea what that documentation includes but it might contain everything that you need.

Hi, thanks for your reaction. I’ll try this next week en post the outcome on the forum!

Thanks for the good advice! Today I followed the tips and it quickly became clear how I could get it done.
Every 4 pixels can be controlled with hex codes, which makes it possible to design a logo. I’ll post the translation table later this week. By the way, the code I posted was everything what was delivered with the matrix, so that brought me no further. by controlling the case per 4 pixels, you can make everything you want visible on the matrix. I have created a tool in Excel that makes this easy to achieve. I will also post this file this week.

As promised, here are the codes:

use them from left to right and from up to down

image

Images for 2nd and 5th lines are the same, but codes are different?
Again, codes for 3rd and 9th lines and for 10th and 12th lines are the same, but images are not...
And in general, here should be 16 lines for 4 bitfields, but you show 14 only

I think you got confused when deducing the values. Moreover, I think the task is simpler - 2 bits should be allocated for each pixel in the code, and I think they are always the same.

Hi Edison,

Thanks for your response, it is indeed true that there must be 16 combinations. Sorry, I posted the wrong file. Here is the correct file with 16 codes. When making a logo I still miss the combination 0101, so let's see how I can do that!

image

It cannot be that there are 16 DIFFERENT options and there is no option 0101.

And for sure - the pictures in the 4th and 7th row are the same

And in general, you don't need this table at all.
The coding scheme is quite simple.
Pixels coded with two bits each, in inverse (bits 11 means the pixel is OFF, 00 - is ON).
If we name pixels as p1 -p4 from left to right, the coding will be:

  p1 - bits[0:1]
  p2 - bits[2:3]
  p3 - bits[4:5]
  p4 - bits[6:7]

You are right, and I found 0101:

image

Thanx!

sorry again, but the codes for
0001 - 0x1a
and
0101 - 0x11
are seems to be wrong

see the post#12

Hi Edison,

Thanks for your support, with the current codes it works for me. But I always want to know how I can do better. I don't understand your explanation, what hex value should there be for example 0001?

0001 should be 0xf3
0101 will 0x33

with which "current codes"?
you've changed your codes 4 times in the last day, so which ones work? :slight_smile:

Hi Edison, that's right, I'm making a mess of it :crazy_face:. Post 13 contains the correct codes that work for me. I am happy with your advice. That takes me further!

sorry i got confused too

0001 should be 0x3f

Good luck for your project

Thanks to Edison's contribution, the question has been answered. Below are the correct codes!

image

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.