0

hello fellow arduino programmers, im currently working on a LED matrix where im driving a 30x7 (210led WS2812) matrix. im usng a arduino nano for this job.

i found this part of code on the internet, but this is using the octoWS2811 library, and i like to get this working without the ws2811 octo library, as this is only for teensys.

the original code looks like this:

#include <OctoWS2811.h>

#include<OctoWS2811.h>
#include<FastLED.h>

// ------------ Change these as neccesary -----------//
#define NUM_LEDS_PER_STRIP 400
#define NUM_STRIPS 8

CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
const int numOfBytes = NUM_LEDS_PER_STRIP * NUM_STRIPS * 3;
const int numLeds = NUM_LEDS_PER_STRIP * NUM_STRIPS;
 char inputBuffer[numOfBytes];

// ------------------- Setup -------------------- //
 void setup() {
  LEDS.addLeds<OCTOWS2811>(leds, NUM_LEDS_PER_STRIP);
  LEDS.setBrightness(255);
  delay(500);
  Serial.begin(115200);
  Serial.setTimeout(500);
  LEDS.show();
}

// ------------------- Main Loop -------------------- //
void loop() {
if(Serial.available() > 0) {
  Serial.readBytes(inputBuffer, numOfBytes);
}
  for (int j = 0; j < numLeds; j++) {
    leds[j] = CRGB(inputBuffer[(j*3)],inputBuffer[(j*3)+1],inputBuffer[(j*3)+2]);
  }
  LEDS.show();
}

and i want it to work with something like this:

#include<FastLED.h>

// ------------ Change these as neccesary -----------//
#define NUM_LEDS_PER_STRIP 400
#define NUM_STRIPS 8

CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
const int numOfBytes = NUM_LEDS_PER_STRIP * NUM_STRIPS * 3;
const int numLeds = NUM_LEDS_PER_STRIP * NUM_STRIPS;
 char inputBuffer[numOfBytes];

// ------------------- Setup -------------------- //
 void setup() {
 FastLED.addLeds<NEOPIXEL, 3>(leds, 0, Num_Leds);
 FastLED.addLeds<NEOPIXEL, 4>(leds, Num_Leds, Num_Leds);
 FastLED.addLeds<NEOPIXEL, 5>(leds, 2 * Num_Leds, Num_Leds);
  FastLED.addLeds<NEOPIXEL, 6>(leds, 3 * Num_Leds, Num_Leds); -------to let fastled know it should be seen as a single led-strip
  FastLED.addLeds<NEOPIXEL, 7>(leds, 4 * Num_Leds, Num_Leds);
  FastLED.addLeds<NEOPIXEL, 8>(leds, 5 * Num_Leds, Num_Leds);
  FastLED.setBrightness(255);
  delay(500);
  Serial.begin(115200);
  Serial.setTimeout(500);
  FastLED.show();
}

// ------------------- Main Loop -------------------- //
void loop() {
if(Serial.available() > 0) {
  Serial.readBytes(inputBuffer, numOfBytes);
}
  for (int j = 0; j < numLeds; j++) {
    leds[j] = CRGB(inputBuffer[(j*3)],inputBuffer[(j*3)+1],inputBuffer[(j*3)+2]);
  }
  FastLED.show();
}

any suggestions on this? it should be a simple streaming piece of code but i cannot figure out how to get this to compile using the fastled library and NEOPIXEL/ws2812 leds.

Igor D
  • 108
  • 2
  • 12
  • Why not read for example the library documentation? https://github.com/FastLED/FastLED/wiki Just as help? – Adriano Nov 06 '19 at 08:45
  • i did. the problem is that the code is written for a teensy, and i like to run it on a normal arduino. the octo library is only run with a teensy but as i do not have one of those i need to transform the code to work with an arduino – Igor D Nov 07 '19 at 14:39
  • no, not the octoLibrary. Documentation of the FastLED. The library has the same syntax for Arduino and Teensy. If it does not compile, probably it is because you are requesting 400x8x32 bytes (100k)! – Adriano Nov 07 '19 at 16:31

0 Answers0