0

I'm working a little project using a neopixel like matrix board. The board in question is here. Now this is my first adventure into addressable led boards. And I was extremely frustrated to learn that the board came with zero documentation nor was there really anything about it on the internet. I did eventually find some docs on the LEDs on the board.

They are the WS2812b, The docs are here. So I've written some code based on my perception of how it works. The docs arent really the best. So I'm sure i'm misunderstanding it.

Heres the code for it.

using namespace std;
#define DATA 23


void send1()
{
    //T1H
    digitalWrite(DATA, HIGH);
    usleep(0.85);
    //T1L
    digitalWrite(DATA, LOW);
    usleep(0.4);
}

void send0()
{
    //T0H
    digitalWrite(DATA, HIGH);
    usleep(0.4);
    //T1L
    digitalWrite(DATA, LOW);
    usleep(0.85);
}

void sendReset()
{

    //Treset
    digitalWrite(DATA, LOW);
    usleep(55);
}


int main(void)
{
    wiringPiSetupSys();
    while (true)
    {
        //256 pixels total
        for (int i = 0; i < 256; i++) {
            //3 bytes GRB
            for (int a = 0; a < 3; a++) {
                //G set to 0
                for (int g = 0; g < 8; g++) {
                    send0();
                }
                //R set to 255
                for (int r = 0; r < 8; r++) {
                    send1();
                }
                //B set to 0
                for (int b = 0; b < 8; b++) {
                    send0();
                }
            }
            //reset after bytes sent
            sendReset();
        }

            
    }
    return 0;
}

Heres the result

enter image description here

As you can see it doesn't work at all!

Using that code I ran a scope on my gpio pin and this is what that looks like.

enter image description here

I've been working on this for a few hours and the most I've been able to do is turn on all the LEDs to white. And I did that with this code

    while (true) {
        digitalWrite(DATA, HIGH);
        digitalWrite(DATA, LOW);
    }

This does reliably turn everything white at least.

enter image description here

Arcalise76
  • 56
  • 7
  • The hint I find on the amazon page is `"download the Adafruit_NeoPixel library from GITHUB"` -- which is where I would start by looking at the code. Since the panel is 8x32 I would suspect you should be able to supply some type of 256-byte buffer to the controller where each 8-bit value will be used to control an LED (my guess). Take a look at the code, or search for the data-sheet for the controller model. – David C. Rankin Dec 09 '21 at 05:39
  • I saw that comment. They dont support the pi. But from my scope it appears that the pi should be capable of doing this. So I'm working on it. – Arcalise76 Dec 09 '21 at 05:41
  • I do work with the TI boards. Much of the Arduino and Pi code is written in C. They are usually decently commented. I've found you can get a good idea of how something unfamiliar works that way. Good luck. – David C. Rankin Dec 09 '21 at 05:45

0 Answers0