Hi all,
First of all i am totally new to programming, arduino and LED matrices. But since i saw LED matrices on the net and how
awesome their lightshows can be i ordered a arduino mega, LED matrix 32 x 16 and now im sitting here cheering like a little
boy everytime something works.
Back to topic im gonna show you quick how to display bitmaps on your LED Matrix with the help of the "drawBitmap Function".
What you need:
- Photoshop (or any other similar program)
- Your Arduino and your LED Matrix of any size
Step 1:
Open photoshop and create a new template with the size of your LED Matrix. If you have a LED Matrix with the size of 32 x 16 or
64 x 32 or 8 x 8 you need to create a new file with the exact same size!
Step 2:
Draw your bitmap pixel per pixel. Your picture needs to be in grayscale (black and white) Here is an example what i made:
Now safe it to .jpg or .png it doesnt matter.
Step 3:
Go to this site where you can convert your Image to a Byte Array Image to C++ Byte array (for Arduino & thermal printer)
Upload your picture and it will show you something like this:
//Byte array of bitmap of 32 x 16 px:
img [] = {
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x80, 0x0, 0x0, 0x7, 0xf0,
0x0, 0x0, 0xd, 0xa0, 0x0, 0x0, 0x1c, 0xf0, 0x0, 0x0, 0x1f, 0x90, 0x0, 0x0, 0x7,
0xe0, 0x0, 0x0, 0xe, 0x40, 0x0, 0x0, 0x1a, 0x70, 0x0, 0x0, 0x19, 0x98, 0x0, 0x0,
0x1f, 0xf8, 0x0, 0x0, 0x6, 0x60, 0x0, 0x0, 0xe, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
}
The only part we need is this one:
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x80, 0x0, 0x0, 0x7, 0xf0,
0x0, 0x0, 0xd, 0xa0, 0x0, 0x0, 0x1c, 0xf0, 0x0, 0x0, 0x1f, 0x90, 0x0, 0x0, 0x7,
0xe0, 0x0, 0x0, 0xe, 0x40, 0x0, 0x0, 0x1a, 0x70, 0x0, 0x0, 0x19, 0x98, 0x0, 0x0,
0x1f, 0xf8, 0x0, 0x0, 0x6, 0x60, 0x0, 0x0, 0xe, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
Safe it in a textfile somewhere or just leave the website open to copy it later.
Step 4:
Now open Arduino and create a new sketch. Copy this into your sketch:
By the way i used a Arduino Mega so you will probably need to change Ports in the code if you use an Arduino Uno or
something else
// Create some cool bitmaps on your Matrix
// For 16x32 RGB LED matrix.
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define CLK 11 // MUST be on PORTB!
#define LAT A3
#define OE 9
#define A A0
#define B A1
#define C A2
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 32
const unsigned char PROGMEM bitmap[] =
{
// Add the Byte Array here!
};
void setup()
{
matrix.begin();
// miniature bitmap display
matrix.drawBitmap(0, 0, bitmap, 32, 16, matrix.Color333(7,3,1));
}
void loop() {
// do nothing
}
Step 5:
Now copy your Byte array and paste it in the sketch where it says:
{
// Add the Byte Array here!
};
It should look like this:
{
// Add the Byte Array here!
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x80, 0x0, 0x0, 0x7, 0xf0,
0x0, 0x0, 0xd, 0xa0, 0x0, 0x0, 0x1c, 0xf0, 0x0, 0x0, 0x1f, 0x90, 0x0, 0x0, 0x7,
0xe0, 0x0, 0x0, 0xe, 0x40, 0x0, 0x0, 0x1a, 0x70, 0x0, 0x0, 0x19, 0x98, 0x0, 0x0,
0x1f, 0xf8, 0x0, 0x0, 0x6, 0x60, 0x0, 0x0, 0xe, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
};
Its done! Now upload your sketch to your arduino and you can see your bitmap on the LED Matrix
Result:
The next thing i want to try is how to play animations with bitmaps like showing one bitmap after bitmap to create an
illusion of animation.