APA102 LED STRIP Matrix + Arduino Uno!

First, I`m not born in English speaking country. Maybe I will use bad English.

Arduino Uno
APA102C 8x32 LED STRIP Matrix - I bought here Pololu - Addressable RGB 8x32-LED Flexible Panel, 5V, 10mm Grid (APA102C)

I`m not good at coding with arduino, but I must do arduino coding because of my senior project.

Plz help me!

I found around 4days and I can`t find anything examples.
My head overrun.

My question is.. I want to make arrow like this '→←↔' in LED matrix.
or just I want to point in the direction. Flashing is better!

Have you loaded the Pololu library from that page and tried the examples sketches that come with it? Don't they give you any useful ideas about how to use the LED strip?

Steve

I found around 4days and I can`t find anything examples.

The Pololu library includes 6 examples.

Well I used that. but I don`t have any idea.

I found some Youtube, and I can found this ESP32 #8: APA102 RGB LED Strip controlled by Arduino Sketch - YouTube

and I changed the code like this.

#define clockPin 12     // GPIO-PIN
#define dataPin 11     // GPIO-PIN
#define MAX_COLORS 256  // Number of APA102 LEDs in String

static uint32_t looppos;

typedef struct colorRGBB  {
   uint8_t red, green, blue, brightness;
} colorRGBB;

void writeByte(uint8_t b) {
 uint8_t pos;
 for (pos=0;pos<=7;pos++) {
    digitalWrite(dataPin, b >> (7-pos) & 1);
    digitalWrite(clockPin, HIGH);
    digitalWrite(clockPin, LOW);
  }
}

void startFrame() {
 //Serial.println("startFrame");
 writeByte(0);
 writeByte(0);
 writeByte(0);
 writeByte(0);
}

void endFrame(uint16_t count) {
 //Serial.println("endFrame");
 writeByte(0xFF);
 writeByte(0xFF);
 writeByte(0xFF);
 writeByte(0xFF);
}

void writeRGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness) {
 writeByte(0b11100000 | brightness);
 writeByte(blue);
 writeByte(green);
 writeByte(red);
}

void writeColor(colorRGBB color) {
 writeRGB(color.red, color.green, color.blue, color.brightness);
}

void writeColors(colorRGBB * colors, uint16_t count) {
 //Serial.println("writeColors");
 startFrame();
 for(uint16_t i = 0; i < count; i++) {
   writeColor(colors[i]);
 }
 endFrame(count);
} 

void setup() {
 Serial.begin(115200);
 Serial.println("Hello ESP32 from Arduino setup");
 digitalWrite(dataPin, LOW);
 pinMode(dataPin, OUTPUT);
 digitalWrite(clockPin, LOW);
 pinMode(clockPin, OUTPUT);
 looppos=0;
}

void Blink(uint32_t loops, uint16_t delayms) {
 colorRGBB RGB[MAX_COLORS];
 uint8_t bpos,bdir;

 bpos=0;
 bdir=0;
 for(uint32_t pos = 0; pos < loops; pos++) {
   for(uint16_t i = 0; i < MAX_COLORS; i++) {
     
    RGB[i].red=0;
    RGB[i].green=0;
    RGB[i].blue=0;
    RGB[i].brightness=0;
   }
  
    writeColors(RGB, MAX_COLORS);
    delay(delayms);

 }
}

void Rightsignal(uint32_t loops, uint16_t delayms) {
 uint8_t bpos,bdir;
 colorRGBB RGB[MAX_COLORS];

 bpos=0;
 bdir=0;
 for(uint32_t pos = 0; pos < loops; pos++) {
    RGB[0].red=255;
    RGB[0].green=228;
    RGB[0].blue=0;
   for(uint16_t i = 1; i < MAX_COLORS; i++) {
     
    RGB[i].red=RGB[0].red;
    RGB[i].green=RGB[0].green;
    RGB[i].blue=RGB[0].blue;
    RGB[i].brightness=1;
   }
  if (bdir==0) {
     bpos++;
   } else {
     bpos--;
   }
   if (bpos>=31) {
      bpos=1;
      bdir=1;
   }
   if (bpos==0) {
      bpos=1;
      bdir=0;
   }
    writeColors(RGB, MAX_COLORS);
    delay(delayms);

 }
}

void loop() {
 Serial.print("Hello ESP32 from Arduino loop ");
 Serial.println(looppos);

 Rightsignal(5,5);
 Blink(5,5);
   
}

When I run this, it is all turned on like fade, but You can see It turn on from the startframe to the endframe, So I called Rightsignal.

On the contrary, I want to turn on from the endframe to the startframe. then I can call that Leftsignal.

Why are you making life difficult for yourself?

You are not using the libraries that would make your code so much easier to write. You need all the help you can get because as you know your code writing is poor.

The endFrame function has errors. First you pass into it a value and never use it and second you don't provide enough pulses. You only provide 32 and you need 32 + half the number of LEDs. So for 256 LEDs you need to provide 160 pulses.

Finally you are trying to write an algorithm to set up the arrow shape, why? It is much easier to define an array with the LED numbers you want to write to and then have a simple loop that reads each value in this array and sets that LED number.