Documente Academic
Documente Profesional
Documente Cultură
Making an Arduino animated frame with 256 RGB Leds! Home / Tutorials / Making an Arduino animated frame with 256 RGB Leds!
TUTORIAL OVERVIEW
Couple of years ago, I saw someone create an animated picture frame using a 16×16 matrix of RGB LEDs and I
thought it was the coolest thing ever!
Since I’m a big retro arcade gaming fan, *I grew up in the 80’s when arcades were still a thing*, I wanted to create
one for myself.
The one I saw was using a Raspberry Pi to drive all the LEDs, but I wondered if you could do the same kind of
thing using the Arduino.
Making a 16×16 RGB Matrix
animated frame using an Arduino
Since the Arduino’s have no where near the amount of memory available on the Raspberry Pi, I wasn’t sure how
– many animated characters I could create on an Arduino.
I realized that since the character information which is stored in arrays doesn’t change (meaning that I never
update the info) I could save it in Flash memory instead of SRAM where the sketch gets executed normaly.
Since Arduino’s have much more Flash memory available than SRAM, I could store all my character information
there and have more space available to create many more. I was worried that using Flash memory might be too
slow, but it worked just ne.
Get your
premiums back*^ Here’s an example of the amount of memory available on the UNO:
on completion of
policy term Flash 32k bytes compared to only 2k bytes of SRAM.
To create the 16×16 matrix of LEDs, I used regular WS2812B LED strip, the one I used have 60 LEDs per meter,
which gave adequate spacing between the LEDs.
You also need to create some sort of grid to isolate the LEDs from one another, I used my Laser Cutter to create
the grid but you could also nd something that works at the hardware store.
*^Total premiums paid inclusive of any extra premium but
exclusive of all applicable taxes, cesses or levies
and modal extra. Return of premium option is available on
payment of additional premium. | *Disclaimer. One example would be to use a suspended ceiling light grid.
Max life smart term plan (UIN: 104N113V01). Non linked.
Non participating. | ARN: 150719/IM/TROP
HELP OUT
/
All my content is free. CONNECTIONS
Since I’m using a WS2812 LED strip, I only need one connection from the Arduino to control all 256 LEDs.
The led strip I’m using has 60 LEDs per meter and have 3 pins: 5V, GND, and DATA.
Pin 3 of the Arduino MEGA is connected to the Data Pin at the start of the LED strip.
I also connected a 470 ohms resistor inline to protects the Arduino output port from over voltage that could
damage the rst LED in the strip, this is good practice but never had a problem without one, so it’s optional.
At the end of the rst strip you then connect the VCC, GND, and DATA pin to the LED strip below it, and keep
doing this until you reach the end.
To power all these LEDs you will need a pretty beefy 5V power supply since the Arduino cannot supply power to
that many LEDs.
In theory if all 256 LEDs are lit at 100% brightness and white in color, then the total power consumption would be
around 16A.
I connect a capacitor to smooth out the uctuating current draw by the LED strip, in this case a 1000uF 10V,
again this is optional but good practice.
Since I’m only use 15% brightness and not all the LEDs will be lit up white at any time, I’m using a 5V 10A power
supply which is enough for my purposes.
To make sure I don’t get a big voltage drop, I’m connecting the VCC and GND from the power supply to the VCC
and GND at the start end end of the LED strip.
/
THE CODE
Like I said at the beginning I want to save the character animation frames to Flash instead of SRAM.
To achieve this I’m using the PROGMEM command to save the arrays to Flash. You can see this in the code when I
create the array and when I read from it.
In the sketch below you will see 6 arrays for a total of 3 characters.
Each character has 2 array or frames to create a simple animation for each one. Of course you can create as many
as you want as long as you have Flash memory available.
Each array has 256 HTML color values that represent each LED in the 16×16 matrix.
As always for more information about the tutorial and explanation of the code please watch our tutorial video.
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
*/
// Create the array of retro arcade characters and store it in Flash memory
const long DigDug01[] PROGMEM =
{
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x00000
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xccccc
0x000000, 0x000000, 0x000000, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0x00000
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcccccc, 0xcccccc, 0xccccc
0x000000, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0xccccc
0x000000, 0x000000, 0x000000, 0x000000, 0x0066cc, 0x000000, 0x0066cc, 0x000000, 0x0066c
0x000000, 0xcccccc, 0xcccccc, 0xcccccc, 0x0066cc, 0x0066cc, 0x0066cc, 0x0066cc, 0x00000
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x0066cc, 0x0066cc, 0x0066cc, 0x0066c
0x000000, 0x000000, 0x000000, 0x0066cc, 0x0066cc, 0xcccccc, 0xcccccc, 0xcccccc, 0xccccc
0x000000, 0x000000, 0xff0000, 0xff0000, 0x000000, 0xcccccc, 0xcccccc, 0xcccccc, 0xccccc
0x000000, 0xff0000, 0xff0000, 0xff0000, 0x0066cc, 0x0066cc, 0x0066cc, 0x0066cc, 0xff000
0x000000, 0x000000, 0xff0000, 0xff0000, 0x000000, 0xcccccc, 0xcccccc, 0xcccccc, 0x0066c
0x000000, 0x000000, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0xccccc
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcccccc,
0xccccc
/
0x000000, 0x000000, 0xcccccc, 0xcccccc, 0xcccccc, 0xcccccc, 0x000000, 0xcccccc, 0xccccc
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x00000
};
void setup() {
FastLED.addLeds<NEOPIXEL,DATA_PIN>(leds, NUM_LEDS); // Init of the Fastled library
FastLED.setBrightness(15);
}
void loop() {
FastLED.clear();
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = pgm_read_dword(&(Qbert01[i])); // Read array from Flash
}
FastLED.show();
delay(500);
FastLED.show();
delay(500);
FastLED.clear();
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = pgm_read_dword(&(DigDug01[i]));
}
FastLED.show();
delay(250);
FastLED.show();
delay(250);
/
// Put BombJack first frame
for(int passtime = 0; passtime < 8; passtime++) {
FastLED.clear();
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = pgm_read_dword(&(BombJack01[i]));
}
FastLED.show();
delay(400);
FastLED.show();
delay(400);
TUTORIAL VIDEO
DOWNLOAD
Copy the above Sketch code you want to use above in your Arduino IDE software to program your Arduino.
Download the Fastled Library created by Daniel Garcia and Mark Kriegsman here: Fastled.io
/
Like this? Share it with others
Related Posts
34 Comments
Wonderful project looking forward to building one. How hard would it be to store and read the arrays from an sd card? You could have a Mario card, pac-
man card etc.
Hello, I used Raspberry Pi to complete a 32×16 module like yours, but when I made the shell, I found that I couldn’t nd a material like yours to make the
whole screen look black and bright. Could you tell me the name of the material you are using or the address of them on ebay or Amazon? thanks a lot
Hi, I have to make a university project with a sort of display (60 LED/m), The size of that display is: 350×116.66mm and the resolution is 21×7, instead of
16×16. What’s the size of the frame needed for this type of display?
has no one else noticed that this would never work if connected as shown in the diagram.? Outputs are connected to Outputs and Inputs are connected to
Inputs.
So which is it…are the direction arrows wrong or is the wiring wrong. ?
Good catch! I’ve updated the diagram to show the correct arrow directions.
I just spent about three hours trying to get this working. I eventually got it and just want to leave a comment for any other internet travelers that might
run into a similar problem.
I’m using a premade 16×16 matrix I got from ebay, running off a genuine Uno.
Everything was green, and updating the libraries and IDE did nothing.
https://github.com/FastLED/FastLED/issues/90 This thread mentions it’s the result of the timing being off, causing a green bit to be sent whether you
want it or not. Things that should have been black were green, and every other color had a green tint over it. /
Eventually, the Arduino IDE gave me a popup saying I had boards and libraries out of date, and I used the Boards Manager to update “Arduino AVR
Boards” to version 1.6.23, and that solved it.
Maybe it’s something simple enough that other people would think to check, but not me. But hopefully I can save someone else three hours of
troubleshooting, as this page is in the top results for 16×16 LED matrix tutorials.
To OP – thanks for all the heavy lifting to get the project started, I can’t wait to design my own sprites and animate them!
Thank you for taking the time to share your experience and solution. Good luck with your project!
Great Project. I know you don’t have the laser les, but do you have the total thickness in mm of those 3 pieces (2 mdf, 1 black) that you used between the
glass and The mounting plate. Thanks!
Hi! Would a 1/4 Watt 470 ohm resistor work with WS2811 LED pixels?
A 1/4 Watts 470ohms resistor will work just ne with WS2811 as well as WS2812.
Hi! Thank you for this, you’re amazing! I’m doing a similar project on a slightly larger scale with WS2811 LED pixels that come in 50 pixel strands (needing
5 strands plus 6 more pixels to make a 16 x 16 256 pixel matrix). These strands have 3-pin JST-SM connectors (5V, Data, Ground) to chain strings together
and extra pigtails for “5V” and “Ground” at the beginning and end of each strand. I was wondering if it’s okay to use one power supply but run the 5V and
grounds in parallel to distribute (inject) and solve any voltage drop issues. What do you think?
Hi Brian, you can use the same power supply to inject 5V and GND to the Start and the End of the LED strip, as long as the power supply you are
using is strong enought (Amp wise) to supply all the LED’s connected. Hope this is what you meant by your questions? Cheers!
After reading your comment again, I understand what you meant: You have a JST connector at the Start and End of your LED strip, but also have 2
extra wires (5V and GND) as well. I believe those extra wires are connected to the same connector that the 5V and GND on the JST are, so if that’s
the case, it shouldn’t matter which one you use. But you could use only the Data wire on the JST to connect the Arduino, and use the separate 5V
and Ground wires to supply power at the Start and End of your LED strip. Hope that helps! Cheers!
One other great hack I discovered while building this: I did not cut up my 5M LED strip into pieces and use connectors. If you bend it at each turn, it takes
up two LEDs (wasted) on each turn. There are 15 turns, which uses up 30 LEDs. Then there are about 8 or so left over at the end. Then you can plug into
both connectors built into the ends of the strip (no soldering or cutting wires). And you do not need those plastic connectors. I found some connectors
that worked ne, but there are many that do not work well. And one bad connection and you’ll be pulling your hair out. To compensate for the extra LEDs
in the strip, I just wrote a quick translation program that takes the incoming sprite and ignores the LEDs in the turns. It is lightning fast and works great!
Had to share because it is MUCH easier than the connectors! Thanks for a great tutorial!
Would there be a conceivable way to maybe link the display to say an IR Proximity sensor so that when I am close to it, the character changes to show
maybe the date or the time? or since everything is done in ash at runtime there is not a way to change things like that? Also, thanks for the tutorials
they’ve been a great teaching resource for myself.
I am a little new to this, but how did you turn the image you wanted into the html array? Thanks
what connector did you used to connect the RGB LED Strip ? I’m referring the connector on time 2:04 of this tutorial . Thanks in advance
This has been a really fun project and I am de nitely learning a lot. I have been making my own graphics and got to the point where I wanted to make a
scrolling text. I couldn’t nd any code to help me do it the easy way…..Sooo I did it the hard way and just put a bunch of single les at faster refresh rate to
make an animation of scrolling text. My text is simple and is 64 frames big. I’m using a Mega and it seems that I am using about half the available memory. I
placed this code for the 64 frames at the end of all my other pics/animations, but for some reason it seems that I don’t understand the order in which the
code works. I just put the code for each picture after the other in order I wanted them to run, but the code runs from the bottom of my script. I placed the
same code at the beginning and all my code run in about 2 seconds. I have only copy and pasted making everything exactly like your example script. Is
there something that you can put in a script to make it run a different order? OR is there a way that some scripting could get stuck in the memory and not
re-write when I give it new one? If I run each piece separate it seems to work ne….its only when I put the two together that it throws me off. I was going
to try it on my uno, but the le is too big. Maybe there’s a simple explanation? Thank you again for such a fantastic website!
Hi, Josh. Have the same problem. Have you nd the solution?
I tried it on my Nodemcu, it worked rly well. But after a short time the array or so broke up? So sometimes the picture got ripped off and idk why – can’t x
it. Maybe it’s the delay or the data connection? Maybe you know what happend (sry for the english im from germany :D). Btw thank you for this great
project !
how could i edit the code if im making a 10×10 pixel frame sorry it sounds dumb but im new to programming
Hi, very nice project! Can you tell an approx budget to get all this done? Thx.
This is great I even went out and bought the 16 x 16 led board to use with my Arduino as well. Thanks for the code and tutorial, de nitely. My question is
does anyone have a link possibly for more arduino codes for the 8bit characters?? I am dying to nd more of them been searching w/ not much luck…. PS I
am somewhat new to all of this as well.
/
brainy-bits April 28, 2018 at 5:11 pm - Reply
Hi, I did make another tutorial video showing how I created the arrays that hold the 8bit characters. You can nd it here: https://www.brainy-
bits.com/create-arduino-array-from-pictures/
Hope that helps!
Hey! I love the way you did this! I’ve been racking my brain trying to work out the box, I don’t suppose you could share your laser cutter les? 🙂
Sorry for the late reply, I will put the les available for download here soon!
Just nished putting this together, have added several sprites to it. Great instructions. This is going on display in my arcade room.
The Laser cut les would be sweet if you could share those. Added a few bucks to your tip Jar Thanks for this. Awesome.
Hi, thanks for your comment, great to hear you built one! Thanks for the tip as well 😉 I’ll try to dig up the laser .DXF les and put them
here. Cheers!
Hi, I’ve checked for the les, but the only ones I have left are from LaserCad and it seems I’ve deleted the Adobe Illustrator versions…
Doohhh! Sorry about that, but next time I create anything that involves the Laser Cutter, I will put the Illustrator or DXF les available
for download.
Like I told Nick, it seems I’ve deleted the Adobe Illustrator versions… and only have the LaserCad versions. Next time I will make available the
Illustrator version or DXF les for download. Sorry about that…
Leave A Comment
Comment...
POST COMMENT
/