So I have my LEDs wired up like so:
https://drive.google.com/file/d/1jEYeARouquBPcyslEqkxDTgFp2SQkvYU/view?usp=sharing
The problem is, those wires with the red marks are not turning on. All the other LEDs do. I am using WS2812B LEDs, so if one LED goes bad, the rest should still light up. I took the LED strip that wouldn't turn on and tested it individually to see if it would light up, and it is. I suspect it's a problem with the LEDs, but I can't figure out what is wrong with them. Or can you think of there being something wrong with the program? It's a basic for loop that blinks all off the LEDs. Here is my program:
I also made modifications to OctoWS2811.cpp to account for my backwards data pin wiring.
Even without that switch statement, those 2 LED strips still won't light up. Help!
https://drive.google.com/file/d/1jEYeARouquBPcyslEqkxDTgFp2SQkvYU/view?usp=sharing
The problem is, those wires with the red marks are not turning on. All the other LEDs do. I am using WS2812B LEDs, so if one LED goes bad, the rest should still light up. I took the LED strip that wouldn't turn on and tested it individually to see if it would light up, and it is. I suspect it's a problem with the LEDs, but I can't figure out what is wrong with them. Or can you think of there being something wrong with the program? It's a basic for loop that blinks all off the LEDs. Here is my program:
Code:
#include <OctoWS2811.h>
#include <Audio.h>
#include <Wire.h>
#include <SD.h>
#include <SPI.h>
#include <SerialFlash.h>
// The display size and color to use
const unsigned int matrix_width = 18;
const unsigned int matrix_height = 60;
const unsigned int myColor = 0x020000;
bool switchh = true;
// These parameters adjust the vertical thresholds
const float maxLevel = 0.99; // 1.0 = max, lower is more "sensitive"
const float dynamicRange = 40.0; // total range to display, in decibels
const float linearBlend = 0.3; // useful range is 0 to 0.7
// OctoWS2811 objects
//const int ledsPerPin = matrix_width * matrix_height / 8;
const int ledsPerPin = 360; // this is how much LEDs there are per pin, 6 meters of LEDs
DMAMEM int displayMemory[ledsPerPin*6];
int drawingMemory[ledsPerPin*6];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerPin, displayMemory, drawingMemory, config);
// Run setup once
void setup() {
delay(3000);
// the audio library needs to be given memory to start working
AudioMemory(20);
leds.begin();
leds.show();
}
// A simple xy() function to turn display matrix coordinates
// into the index numbers OctoWS2811 requires. If your LEDs
// are arranged differently, edit this code...
unsigned int xy(unsigned int x, unsigned int y) {
if ((x & 1) == 0) {
// even numbered rows (0, 2, 4...) are left to right
return (x * matrix_height) + y;
} else {
// odd numbered rows (1, 3, 5...) are right to left
return (x * matrix_height) + matrix_height - 1 - y;
}
}
void loop() {
unsigned int x, y;
//float level;
for (x = 0; x < 47; x++) {
for (y = 0; y < matrix_height; y++) {
if (switchh) {
leds.setPixel(xy(x, y), myColor);
} else {
leds.setPixel(xy(x, y), 0x000000);
}
//Serial.print(xy(x, y));
//Serial.println();
//delay(600);
//leds.show();
}
}
leds.show();
switchh = !switchh;
delay(1000);
}
I also made modifications to OctoWS2811.cpp to account for my backwards data pin wiring.
Code:
void OctoWS2811::setPixel(uint32_t num, int color)
{
uint32_t strip, offset, mask32, *p;
switch (params & 7) {
case WS2811_RBG:
color = (color&0xFF0000) | ((color<<8)&0x00FF00) | ((color>>8)&0x0000FF);
break;
case WS2811_GRB:
color = ((color<<8)&0xFF0000) | ((color>>8)&0x00FF00) | (color&0x0000FF);
break;
case WS2811_GBR:
color = ((color<<16)&0xFF0000) | ((color>>8)&0x00FFFF);
break;
case WS2811_BRG:
color = ((color<<8)&0xFFFF00) | ((color>>16)&0x0000FF);
break;
case WS2811_BGR:
color = ((color<<16)&0xFF0000) | (color&0x00FF00) | ((color>>16)&0x0000FF);
break;
default:
break;
}
strip = num / stripLen; // Cortex-M4 has 2 cycle unsigned divide :-)
Serial.print(strip);
Serial.println();
[COLOR="#008000"] switch(strip) {
case 0:
strip = 3;
break;
case 1:
strip = 2;
break;
case 2:
strip = 1;
break;
case 3:
strip = 0;
break;
case 4:
strip = 7;
break;
case 5:
strip = 6;
break;
case 6:
strip = 5;
break;
case 7:
strip = 4;
break;
}[/COLOR]
offset = num % stripLen;
p = ((uint32_t *) drawBuffer) + offset * 6;
mask32 = (0x01010101) << strip;
// Set bytes 0-3
*p &= ~mask32;
*p |= (((color & 0x800000) >> 23) | ((color & 0x400000) >> 14) | ((color & 0x200000) >> 5) | ((color & 0x100000) << 4)) << strip;
// Set bytes 4-7
*++p &= ~mask32;
*p |= (((color & 0x80000) >> 19) | ((color & 0x40000) >> 10) | ((color & 0x20000) >> 1) | ((color & 0x10000) << 8)) << strip;
// Set bytes 8-11
*++p &= ~mask32;
*p |= (((color & 0x8000) >> 15) | ((color & 0x4000) >> 6) | ((color & 0x2000) << 3) | ((color & 0x1000) << 12)) << strip;
// Set bytes 12-15
*++p &= ~mask32;
*p |= (((color & 0x800) >> 11) | ((color & 0x400) >> 2) | ((color & 0x200) << 7) | ((color & 0x100) << 16)) << strip;
// Set bytes 16-19
*++p &= ~mask32;
*p |= (((color & 0x80) >> 7) | ((color & 0x40) << 2) | ((color & 0x20) << 11) | ((color & 0x10) << 20)) << strip;
// Set bytes 20-23
*++p &= ~mask32;
*p |= (((color & 0x8) >> 3) | ((color & 0x4) << 6) | ((color & 0x2) << 15) | ((color & 0x1) << 24)) << strip;
}
Even without that switch statement, those 2 LED strips still won't light up. Help!