I'll do the code a little more readable and i'll post it here this weekend, i hope.

here it is!.

It's not a library, and i'm new in arduino and c languaje. Therefore the code will not be the best, i'm sure, but it works and display text with diferents fonts, in the desired position.

The problem with the "canton electronic" function is that it sends to the matrix a buffer matrix with two bits per pixel and reversed bit weight. I can't understand it enough to modify it for working with a bit per pixel and non reversed bytes. Therefore, i paint the text (and another effects) in a more confortable matrix called "canvas" with the function:

textToCanvas(unsigned char *font,int fontHeight, int fontWidth, String message, int row, int column)

only one function to all the text sizes. (only tried with 6x5, 8x8 and 16x16, could be errors with other measures).

After that, i translate the canvas to reversed doble bit with translateCanvasToBuffer(). It moves and translate the canvas to the buffer before send it to the matrix. And finally i send the buffer to the matrix with the original "canton electronics" function. I have added two params to this function, and the setup code, moved to a function for calling it from the main ino project.

There are two versions of this function , one for the arduino One, and another one for the arduino Mega. I only have an arduino mega, therefore i only tried the Mega version. Despite this, you shouldn't have any problems with the UNO version. My code is equal in two cases, and i have done the same changes to the two "display_matrix" funtion versions.

I hope it works for you, and the code gives you ideas to paint another things to the matrix.

Dropbox link:


Hi petabyte,

Your code is very clear and it look well but I would like to know when write any word if that word can remain printed untill I want to print other word.

Thanks for your code.

display_matrix(unsigned char *BMP, int delay_refresco, int sustain)

The sustain parameter is the time text will be visible in the matrix. If you want to do another things with your code while the text is displayed......it's another question...and i think that you can't do that....

Seems that the matrix haven't persistence itself.The canton electronic function does a loop for mantain the send picture. You could simulate it by using interrupts, or some thing like that , but the refresh will do for sure flickering problems. I think this can be the reason for the very low price. Even so, we can buy a cheap 15$ arduino uno only to control the matrix, (sending texts from the main arduino via serial) and still get a very good total cost for a 64x16 matrix. Now i don't need to do this, because my arduino will only display text and some draws and will not do another things, but may be an idea for you.

OK, I will try to creat a library to make my project.
Thanks for your code.

I’ve been playing around with this display a bit and I agree that the code supplied has limited functionality.
However I’ve created an interrupt driven version of the code that constantly scans an 8x32 byte array to address each pixel on the board with ease. Please use any part of this code you guys like.

Matrix_LED_6432_PK.ino (26.9 KB)

Hi Thank you petabyte and kaziewip for your interesting libraries. I have my led 64x16 dot matrix from aliexpress.com http://www.aliexpress.com/item/Indoor-F3-75-P4-75-Single-Red-color-LED-dot-matrix-module-304-76mm-64-16/1721794648.html

Based on petabyte's code I've created an timer/interrupt based version, which runs the matrix in background. In main loop I download data from internet with an ethernetshield an update it on the matrix in fixed time intervals.

Beside the matrix display mechanisme, which could in my opinion be improved, I'm not shure, how the current-limiting could be donne right:

  1. I search more data(sheets) of the matrix it selfe. (led peak current, and for how long the peak max shoud last)
  2. The colum drivers (shift register 74HC595) seem not to be the right thing for their job: max 35mA current per output, total max 70mA current output for the hole IC, 0.5W max Power disipation In multiplexing mode, there are much higher peak currents. http://www.nxp.com/documents/data_sheet/74HC_HCT595.pdf

  3. The row drivers look much more stronger: p-chanel mosfet FDS4953: 5A contiuos current, 20A peak -> each row is only on for 1/16 time. https://www.fairchildsemi.com/ds/FD/FDS4953.pdf

  4. according to this website, i bought the matrix, it's driven 1/16 constant current. But how should the current be constant when in each row a different count of led's are shining?

  5. if one led consumts 10 to 20mA in constant current, it could be peak 100 to 200mA (16x multiplex) a normal led accepts max 10x times the constant current as peak. The whole matrix is on: 64x 100mA = 6.4A per row, always only one row on. -> 8 shift registers for the whole row: 6.4A/8 = 0.8A continous through ONE shift register. In my opinion something doesnt work right here.

Pleas correct me, if me suggestions are wrong.

conclusen: 1. the shift registers are too weak. 2. the current should be limited individually per row, according to the count of led's on in this row.

Hey kaziewip. Nice code for shift registry led matrix displays. :)

I am very new to (trying to) code arduino. Just need to make a led matrix display to hang in the window of my wifes massage salon and have been searching high and low for useful sketches to "borrow" ideas from and learn how the darn language works.

Your sketch is by FAR the best one I've found.

But with my very limited knowledge of coding I have run into some problems. The scrolling text thingie does not scroll onto the screen. The first letter magically appears in the far right part of the display but then scrolls out like it should on the left end.

Have tried to edit every variable I could think of to try to make it have a smooth scroll into the display but no such luck. :/

Could you direct me to where abouts in your code I should edit that?

And my display is 64x16 and I have no idea how to make the top half of my display useful. I tried to switch to big font, but the top part of the font does not scroll, just the bottom part. :/

Also, if anyone can give me tips on how to edit this code so I can use both red and green (and orange) I'd appreciate it. Oh, and anyone know if there is a possibility to dim the display? I only have 2amp psu for it, so might need to lower the intensity to stay within limits.

Thanks for the compliments! :slight_smile:

The code I posted is for a 64x32 LED matrix display and so it doesn’t surprise me that it’ll misbehave on a 64x16 display.

However just after I posted the earlier code, I made some adjustments to drive a 128x16 display (two 64x16 displays connected in series). It should work for just one 64x16 display but it’ll just show LEDs addressed between 64 <= x <= 127.
(It’s a bit inefficient to use this code for just one display but never mind.)

Anyhow, the 128x16 code is attached.

(BlackMajj: in answer to your specific questions, the delay(15) at the end of the code governs the scrolling timing (you’ll need to fiddle with this to get the right answer for your needs) and the moveLeft(1,8,15) only scrolls lines 8 to 15 to the left. If you want the whole thing to scroll then you’d use moveLeft(1,0,15).)

Matrix_LED_12816_PK.ino (27.1 KB)


This code in general won't work for an RG LED matrix, since the software frame buffer in my code only stores the pixels as zeros (off) and ones (on). It would need to be adjusted to use 2 bits per pixel (0=off, 1=red, 2=green, 3=amber).

I also imagine that the electronic addressing of an RG display will also be somewhat different so the "shiftOut" routine would need to be adjusted to take care of this.

Maybe I'll get hold of an RG display and play around with it!

Using a scanning approach like the one I've pursued keeps the power requirements down as much as possible, since you're only displaying one (or two in the case of the 64x32 display) lines of LEDs at a time. You can make the screen dimmer or brighter in software by playing with the interrupt timer variable OCR2A in the "setup" routine (the default value is 97). Note that as it gets dimmer you'll start to see a flicker though :(

Hi Everyone ... thankz kaziewip !!

I did it !! I tested the code for 128x64 ...and work fine for me XD !

... view a video on https://www.youtube.com/v/__iE2CaXtKs&feature=youtu.be

Thanks Again !

I'll try the 128x16 code in the weekend. I suspect that one will give me less of an headache when it's just made for a "longer display".

Thanks a bunch for the tip on where in the code I can get it to scroll all the rows. That vital info will help me a lot, so now I could probably use the 64x32 code as well. :)

Will try to fiddle with the delay(15) and see if it solves the scrolling issue I am plagued with. On the left side when the letters scroll out everything looks right. So a "E" for instance will on the left go from an E to three lines, then three dots and then it's gone. On the right side it just appears as an complete E two columns from the end and starts scrolling to the left. :/ The last two columns never see any action on my display when scrolling text. :~

But I'll see what I can figure out during the weekend. :)

As for the adressing on the red and green, it seems that it just sets either red or green pin high but the rest seems the same. This is a code part from another sketch I found that has the green/red/orange working but no fancy scrolling and such. Just shows clock in green and Hello in red.

                  digitalWrite(oePin, HIGH);
                  digitalWrite(aPin,row & B0001 );
                  digitalWrite(bPin,row & B0010 );
                  digitalWrite(cPin,row & B0100 );
                  digitalWrite(dPin,row & B1000 );
                  digitalWrite(strPin, LOW);
                  shiftOut(redPin, sckPin, MSBFIRST, pbuffer_r[0][row]);
                  shiftOut(redPin, sckPin, MSBFIRST, pbuffer_r[1][row]);
                  shiftOut(redPin, sckPin, MSBFIRST, pbuffer_r[2][row]);
                  shiftOut(redPin, sckPin, MSBFIRST, pbuffer_r[3][row]);
                  digitalWrite(strPin, HIGH);  
                  digitalWrite(oePin, LOW);
                  delayMicroseconds(draw_delay);  // delay for seeing red
                  digitalWrite(oePin, HIGH);
                  digitalWrite(strPin, LOW);
                  shiftOut(greenPin, sckPin, MSBFIRST, pbuffer_g[0][row]);
                  shiftOut(greenPin, sckPin, MSBFIRST, pbuffer_g[1][row]);
                  shiftOut(greenPin, sckPin, MSBFIRST, pbuffer_g[2][row]);
                  shiftOut(greenPin, sckPin, MSBFIRST, pbuffer_g[3][row]);
                  digitalWrite(strPin, HIGH);  
                  digitalWrite(oePin, LOW);
                  delayMicroseconds(draw_delay);  // delay for seeing green


Firstly, apologies for digging up an old thread, I thought it better than starting a new one...

I am using kaziewip's code from post #15, the countdown works great.

However, when I try to get it to display the text in const char message[] or byte buffer[256]

I can't get it to work, the best I could achieve is the message spelling out on the very last panel.

I tried PMing kaziewip to no avail, I don't think he was/is very active on these forums.

Can anybody please tell me what I need to edit/add/remove to have the display read out the message and scroll to the left?

Many Thanks,


Bren - you're right. I've not been around much on the forum. Trying to work with some Uno32s. Try my code in post number 18. This was designed for two 64x16 panels, side by side.

Hello, I have recently purchased a 64x16 LED matrix, I have downloaded the zip file. And thank you guys very much! But, I am have trouble editing the code to have text scroll the entire height of the display, I can remove the clock, the rectangle part, But I cannot seem to combine the upper and lower halves to form one display.

I am also very new to programming.

I need help please, or at least guidance into the right direction. Thanks!!!

Hello guys! I bought this matrix 16x64 here: http://pt.aliexpress.com/item/Indoor-F3-75-P4-75-Single-Red-color-LED-dot-matrix-module-304-76mm-64-16/1721794648.html

So I used this code: https://www.youtube.com/watch?v=4zE6duwytEY,

but I'm having a problem: instead of words the LEDs are off and the rest of the LEDs are lit; I would be grateful for help from someone!

Hi Dancopy, you seem to have posted a link to a video by mistake, instead of a link to the code. Try again.


Sorry Paul,
Here’s the code that video,

shortened_Final_Code_A.ino (17.4 KB)

Try changing

      PORTB |= !((buffer[index]>>(7-i)) & 0x01) << (data_R1-8);  // top set of rows
      PORTB |= !((buffer[index+128]>>(7-i)) & 0x01) << (data_R2-8); // bottom set of rows


      PORTB |= !((~buffer[index]>>(7-i)) & 0x01) << (data_R1-8);  // top set of rows
      PORTB |= !((~buffer[index+128]>>(7-i)) & 0x01) << (data_R2-8); // bottom set of rows

Hello Paul! Note 10++ for you - said and done, it worked perfectly!
I do not want to bother you but I want to ask you these questions:
I have a great desire to do my own codes (sketches) but also have many difficulties in understanding; So I ask you: what is the principle for learning about the codes, especially those arrays as of this review, Led Dot Matrix 64x16 and also these RG Led Matrix?
If for their kindness and gentleness, you want to answer me, I would be very grateful!!
God bless you and all the members of this forum;