32x16 RGB LED Matrix not work properly

Hi!
I am trying with this 32x16 RGB LED Matrix module:

and it not work properly. I followed this instructions:

and examples from the library. I have managed that colors works OK (fill the screen).
But when I want to try shapes, everything is messed.
Then I try to make just a simpel scetch to draw a pixel. And then I see that when I send command to draw a pixel at location x=0, y=0 display draws 2 pixel at location: x=0,y=0 and x=24, y=0.
If I want to draw a pixel at location x=1, y=0 it draws at position: x=7,y=0 and x=23, y=0.
I found this ICs at the module:
ICN2037…24pcs
TC4953ES … 4pcs
MW245B…1pc
ICN74HC138…1pc.

Here is the simple Arduino scetch I am using for drawing a pixel:
#include <RGBmatrixPanel.h>

#define CLK 11
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3

RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);

void setup() {
matrix.begin();
// draw a pixel in white
matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));
}

void loop() {
// Do nothing – image doesn’t change
}

Should I put any additional informations that somebody can help me?
Please advise me.
Thank you and best regards!

Is there anybody who can help me in this matter?
Thank you.

Still nobody who can help me?
While I am waiting for help I make an investigation on this forum.
I found this Topic:

I doenloaded modified Adafruit RGBmatrix library (all 3!) and have limited sucess.
Now X position is correct, but Y not.
Lines goes like: 5,6,7,8,1,2,3,4,13,14,15,16,9,10,11,12.
Can anybody help regardiung this matter?
Thank you and best regards!

So no more 2 LEDs coming on at once when you wanted only one?

Anyway, I thought the library would take care of it, but it looks like you have a mapping problem.

google “led matrix serpentine” and you may find an explanation. You may find a cure, too. I usually set up a mapping array so I can refer to the pixels in a normal order and the array holds values for the actual physical pixels.

Here’s one for a four x four serpentine

const unsigned char map[16] = {0, 1, 2, 3, 7, 6, 5, 4, 8, 9, 10, 11, 15, 14, 13, 12};

Then instead of

setPixel(xx, color);

you write

setPixel(map[xx], color);

Arrays as maps can also make running things backwards, upside down or rotated as easy as selecting which of several map arrays to employ in the translation.

HTH

a7

I'm surprised that your sketch doesn't have to tell the library the size of the display.

Thanks for both answers/suggestions.

I am not an expert so I think you are suggesting to situation which I have now, when x position is OK, but y rows are wrong, with modified RGBmatrix library?

Should I make mapping in Arduino code or in Library?
No panel size definition.... Hmm I didn't think on that. But it is Adafruit demo example,I only deleted square, circle, line ... Can I get a suggestion how to define module size?
Thank you!

It’s a matter of opinion. If you modify a library, all who follow in your footsteps must use your improved version.

OTOH if you do it directly in your program, you’ll have to do it in everything you write. Here’s where a personal “library” of handy things to cut and paste (or # include) can start making sense.

Usually everything about the LEDs is specified in the code line that instantiates the code object.

Dunno what’s all in this from your code

RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);

but that’s where I would expect to find dimensions, pin assignments and, perhaps, something to choose among common wiring patterns.

a7

Hi, thank you.
Hmm I am “senior beginner” in Arduino programming. I have some experiences with Arduino code but I never work on libraries. I will need a help regarding this matter. Here is the complete code from RGBmatrix library examples. I do really not see any parameters to set…
// testshapes demo for Adafruit RGBmatrixPanel library.
// Demonstrates the drawing abilities of the RGBmatrixPanel library.
// For 16x32 RGB LED matrix:
// http://www.adafruit.com/products/420

// Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon
// for Adafruit Industries.
// BSD license, all text above must be included in any redistribution.

#include <RGBmatrixPanel.h>

// Most of the signal pins are configurable, but the CLK pin has some
// special constraints. On 8-bit AVR boards it must be on PORTB…
// Pin 8 works on the Arduino Uno & compatibles (e.g. Adafruit Metro),
// Pin 11 works on the Arduino Mega. On 32-bit SAMD boards it must be
// on the same PORT as the RGB data pins (D2-D7)…
// Pin 8 works on the Adafruit Metro M0 or Arduino Zero,
// Pin A4 works on the Adafruit Metro M4 (if using the Adafruit RGB
// Matrix Shield, cut trace between CLK pads and run a wire to A4).

#define CLK 8 // USE THIS ON ARDUINO UNO, ADAFRUIT METRO M0, etc.
//#define CLK A4 // USE THIS ON METRO M4 (not M0)
//#define CLK 11 // USE THIS ON ARDUINO MEGA
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2

RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);

void setup() {

matrix.begin();

// draw a pixel in white
matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));
delay(500);

// fix the screen with green
matrix.fillRect(0, 0, 32, 16, matrix.Color333(0, 7, 0));
delay(500);

// draw a box in yellow
matrix.drawRect(0, 0, 32, 16, matrix.Color333(7, 7, 0));
delay(500);

// draw an ‘X’ in red
matrix.drawLine(0, 0, 31, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(7, 0, 0));
delay(500);

// draw a blue circle
matrix.drawCircle(7, 7, 7, matrix.Color333(0, 0, 7));
delay(500);

// fill a violet circle
matrix.fillCircle(23, 7, 7, matrix.Color333(7, 0, 7));
delay(500);

// fill the screen with black
matrix.fillScreen(matrix.Color333(0, 0, 0));

// draw some text!
matrix.setCursor(1, 0); // start at top left, with one pixel of spacing
matrix.setTextSize(1); // size 1 == 8 pixels high

// print each letter with a rainbow color
matrix.setTextColor(matrix.Color333(7,0,0));
matrix.print(‘1’);
matrix.setTextColor(matrix.Color333(7,4,0));
matrix.print(‘6’);
matrix.setTextColor(matrix.Color333(7,7,0));
matrix.print(‘x’);
matrix.setTextColor(matrix.Color333(4,7,0));
matrix.print(‘3’);
matrix.setTextColor(matrix.Color333(0,7,0));
matrix.print(‘2’);

matrix.setCursor(1, 9); // next line
matrix.setTextColor(matrix.Color333(0,7,7));
matrix.print(’’);
matrix.setTextColor(matrix.Color333(0,4,7));
matrix.print(‘R’);
matrix.setTextColor(matrix.Color333(0,0,7));
matrix.print(‘G’);
matrix.setTextColor(matrix.Color333(4,0,7));
matrix.print(‘B’);
matrix.setTextColor(matrix.Color333(7,0,4));
matrix.print(’
’);

// whew!
}

void loop() {
// Do nothing – image doesn’t change
}

Your code is truncated at the end. Also it should be placed inside code tags.

Oh…I made a mistake while CTRL+C making.
I repaired the code at the end now.

Hi,
After 66 posts.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks... Tom.... :slight_smile:

This is the code:

// testshapes demo for Adafruit RGBmatrixPanel library.
// Demonstrates the drawing abilities of the RGBmatrixPanel library.
// For 16x32 RGB LED matrix:
// http://www.adafruit.com/products/420

// Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon
// for Adafruit Industries.
// BSD license, all text above must be included in any redistribution.

#include <RGBmatrixPanel.h>

// Most of the signal pins are configurable, but the CLK pin has some
// special constraints.  On 8-bit AVR boards it must be on PORTB...
// Pin 8 works on the Arduino Uno & compatibles (e.g. Adafruit Metro),
// Pin 11 works on the Arduino Mega.  On 32-bit SAMD boards it must be
// on the same PORT as the RGB data pins (D2-D7)...
// Pin 8 works on the Adafruit Metro M0 or Arduino Zero,
// Pin A4 works on the Adafruit Metro M4 (if using the Adafruit RGB
// Matrix Shield, cut trace between CLK pads and run a wire to A4).
/*
 R1=D24
 G1=D25
 B1=D26
 R2=D27
 G2=D28
 B2=D29
 A=A0
 B=A1
 C=A2
 D=A3
 LAT=D10
 OE=D9
 CLK=D11
 */

//#define CLK  8   // USE THIS ON ARDUINO UNO, ADAFRUIT METRO M0, etc.
//#define CLK A4 // USE THIS ON METRO M4 (not M0)
#define CLK 11 // USE THIS ON ARDUINO MEGA
#define OE   9
#define LAT 10
#define A   A0
#define B   A1
#define C   A2
#define D   A3

RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);

void setup() {

  matrix.begin();

  // draw a pixel in white
  matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));
  delay(500);
/*
  // fix the screen with green
  matrix.fillRect(0, 0, 32, 16, matrix.Color333(0, 7, 0));
  delay(500);

  // draw a box in yellow
 matrix.drawRect(0, 0, 32, 16, matrix.Color333(7, 7, 0));
  delay(500);

  // draw an 'X' in red
 cmatrix.drawLine(31, 0, 0, 15, matrix.Color333(7, 0, 0));
  delay(500);

  // draw a blue circle
  matrix.drawCircle(7, 7, 7, matrix.Color333(0, 0, 7));
  delay(500);

  // fill a violet circle
  matrix.fillCircle(23, 7, 7, matrix.Color333(7, 0, 7));
  delay(500);

  // fill the screen with black
  matrix.fillScreen(matrix.Color333(0, 0, 0));

  // draw some text!
  matrix.setCursor(1, 0);  // start at top left, with one pixel of spacing
  matrix.setTextSize(1);   // size 1 == 8 pixels high

  // print each letter with a rainbow color
  matrix.setTextColor(matrix.Color333(7,0,0));
  matrix.print('1');
  matrix.setTextColor(matrix.Color333(7,4,0));
  matrix.print('6');
  matrix.setTextColor(matrix.Color333(7,7,0));
  matrix.print('x');
  matrix.setTextColor(matrix.Color333(4,7,0));
  matrix.print('3');
  matrix.setTextColor(matrix.Color333(0,7,0));
  matrix.print('2');

  matrix.setCursor(1, 9);  // next line
  matrix.setTextColor(matrix.Color333(0,7,7));
  matrix.print('*');
  matrix.setTextColor(matrix.Color333(0,4,7));
  matrix.print('R');
  matrix.setTextColor(matrix.Color333(0,0,7));
  matrix.print('G');
  matrix.setTextColor(matrix.Color333(4,0,7));
  matrix.print('B');
  matrix.setTextColor(matrix.Color333(7,0,4));
  matrix.print('*');
*/
  // whew!
}

void loop() {
  // Do nothing -- image doesn't change
}

It looks like that library just knows you are using a specific display 32x64.

Which makes it odd that any issue with wiring order would crop up - one would think that the library would take care of it all.

Is that the example code? Or something you wrote? If the example doesn’t work it makes no sense to look for errors in your code.

a7

Strange. The example you posted does not match the example "testshapes_16x32.ino" that comes with the library.

Could you have an out-of-date version of the library?

Hi,
In an example from the library they have a lot of setup parameters set.
Where are your “mw” and “mh” variables defined.
Please study the examples closely to see how to structure your code.
This library is complex with commands and parameters.

Tom… :slight_smile:

Hi, thank you for your answers.
I downloaded the example from the link above and then compare my example.
Yes, I found few differences and then I remeber that I wrote some changes during finding the problem… last week.
As I mentioned in my posts above in this moment I am using a modified Adafruit RGBmatrix from this Topic: https://forum.arduino.cc/index.php?topic=503416.30

With original library I do not have big success. When I try to write only a pixel, then I saw two pixels, and then they are shifted to the left instead to to right if I increase X value for position, then suddenly change the row position,…

With modified library I have 100% control for X position and partially for Y.
The problem is that Y instead 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 row goes: 5,6,7,8,1,2,3,4,13,14,15,16,9,10,11,12.
I see that on modified library one can connect more than one module so in the line:
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false); one additional parameter is added: RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false,1); . The last paramater (1) determn, to show pixels on the first module.
I am studying this module one week and even first time I opened the library and try to find how this works. But the code in library is written more complicated as I am used from Arduino IDE. I’ve lost in the code.

From the original Adafruit tutorial: Connecting Using RGB Matrix Shield | 32x16 and 32x32 RGB LED Matrix | Adafruit Learning System
I can see now, that they are talking about two module types: 16x32 and 32x32. So I assume the library works only for this two types. I have no idea where and how to tell to software which module you have connect.
I will now follow the siggestion of TomGeorge and goes through all Library examples, maybe I will find something to solve my problem.
Now I am adding modified Adafruit RGBmatrix library.

RGBmatrixPanel.h (2.11 KB)

RGBmatrixPanel.cpp (27.2 KB)

gamma.h (1.51 KB)

Hi!

Unfortunately I have no big progress after all day of work…
I must make a correction of myself: even at X axis module not work correctly 100%
It is hard to express what is happening:
I wrote a simple For loop:

for (int i = 0; i <= 15; i++) {
for (int k = 0; k <= 31; k++) {
matrix.drawPixel(k,i , matrix.Color333(1, 1, 0));
delay(100);
matrix.drawPixel(k,i , matrix.Color333(0, 0, 0));
}
}
The pixels should start in first row at position x=0,y=0. And then increase till X=32.
Then should go in next row …

The result is, it start in 5th row and X moving is ok. It is ok for 6th, 7th and 8th row.
Then it start to first row, but pixels this row goes like 8,7,6,5,4,3,2,1 plce then jump to 16,15,14,13,12,11,10,8, then jump to 24,23,22,21,20,19,18,17, and jump to 32,31,30,29,28,27,26,25 place.
Al lthis rows goes like this, then jump at 12th,13th,14th, and 15th line and x position is OK again in al lthis 4 lines, then jump to 8th,9th,10th and 11th lnie and X goes again like at 1st,2nd,rd and 4th row.

I found in a modified RGBmatrix.cpp libraryin drawPixel function this part:
shift=0;
if (x>7) shift+=8;
if (x>15) shift+=8;
if (x>23) shift+=8;
if (x>31) shift+=8;
if (x>39) shift+=8;
if (x>47) shift+=8;
if (x>55) shift+=8;

if (y < 4 || (y > 7 && y < 12)) shift +=8; // top rows start after lower 8 leds
if (y==1 || y==5 || y==9 || y==13) shift += 32 * 3 * nPanels * nMultiplexRows; // row 1
if (y==2 || y==6 || y==10 || y==14) shift += 64 * 3 * nPanels * nMultiplexRows; // row 2
if (y==3 || y==7 || y==11 || y==15) shift += 96 * 3 * nPanels * nMultiplexRows; // row 3

ptr = &matrixbuff[backindex][shift+x]; // Base addr

I tried to change shift values and other combinations with no 100% success…
I am attaching again modified RGBmatrix library. Maybe someone will look into and find where is the problem. I can not…
Thank you all in advance!

RGBmatrixPanel.cpp (27.2 KB)

RGBmatrixPanel.h (2.11 KB)