OctoWs2811 to 4 x Ws2812b strips / beginner LED programing on different strips

Status
Not open for further replies.

alexthevdwp

New member
So I connected my Teensy3.2 to OctoWS2811 and have 2 ethernet cables plugged in the sockets going to 4 strips of Ws2812b (2 on each cable)

The Rainbow example in the Octo library works but now I would like to program the 4 led strips individually on each ethernet cable and paste parameters and code blocks from for instance: Phillip Burgess Neopixels library or FastLED3.1 to play around.

What are the best ways to do that? I'm just super inspired by these lights and have a tone of ideas that I would like to try out, thanks for your help!

Here's an example of what I would like to do: I would like to run a program like the rainbow chaser sketch on 1 of the 2 strips (of 54 leds each) connected to Ethernet cable #1 and a chasing white strobe on the on 1 of the 2 strips connected to Ethernet cable #2. Can something like this run simultaneously on this set up or does the Octo board only flows for a single program on all led strips?

I'm obviously new to coding LEDs so if you could give me a direction or resources on how to tweet code blocks and parameter for this Teensy3.2 to OctoWS2811 to Neopixels WS2812b set up that would really help.

Below is the code for the Rainbow chaser from the OctoWs2811 drop down example library:
For starters where would I define 1 of the 4 LED strips connected to 2 ethernet cable?
Thanks for your help and time!

/* OctoWS2811 Rainbow.ino - Rainbow Shifting Test
http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
Copyright (c) 2013 Paul Stoffregen, PJRC.COM, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

Required Connections
--------------------
pin 2: LED Strip #1 OctoWS2811 drives 8 LED Strips.
pin 14: LED strip #2 All 8 are the same length.
pin 7: LED strip #3
pin 8: LED strip #4 A 100 ohm resistor should used
pin 6: LED strip #5 between each Teensy pin and the
pin 20: LED strip #6 wire to the LED strip, to minimize
pin 21: LED strip #7 high frequency ringining & noise.
pin 5: LED strip #8
pin 15 & 16 - Connect together, but do not use
pin 4 - Do not use
pin 3 - Do not use as PWM. Normal use is ok.
pin 1 - Output indicating CPU usage, monitor with an oscilloscope,
logic analyzer or even an LED (brighter = CPU busier)
*/

#include <OctoWS2811.h>

const int ledsPerStrip = 54;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

const int config = WS2811_GRB | WS2811_800kHz;

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

int rainbowColors[180];


void setup() {
pinMode(1, OUTPUT);
digitalWrite(1, HIGH);
for (int i=0; i<180; i++) {
int hue = i * 2;
int saturation = 100;
int lightness = 50;
// pre-compute the 180 rainbow colors
rainbowColors = makeColor(hue, saturation, lightness);
}
digitalWrite(1, LOW);
leds.begin();
}


void loop() {
rainbow(10, 2500);
}


// phaseShift is the shift between each row. phaseShift=0
// causes all rows to show the same colors moving together.
// phaseShift=180 causes each row to be the opposite colors
// as the previous.
//
// cycleTime is the number of milliseconds to shift through
// the entire 360 degrees of the color wheel:
// Red -> Orange -> Yellow -> Green -> Blue -> Violet -> Red
//
void rainbow(int phaseShift, int cycleTime)
{
int color, x, y, offset, wait;

wait = cycleTime * 1000 / ledsPerStrip;
for (color=0; color < 180; color++) {
digitalWrite(1, HIGH);
for (x=0; x < ledsPerStrip; x++) {
for (y=0; y < 8; y++) {
int index = (color + x + y*phaseShift/2) % 180;
leds.setPixel(x + y*ledsPerStrip, rainbowColors[index]);
}
}
leds.show();
digitalWrite(1, LOW);
delayMicroseconds(wait);
}
}
 

Attachments

  • Mail Attachment.jpg
    Mail Attachment.jpg
    150.9 KB · Views: 278
Here's an example of what I would like to do: I would like to run a program like the rainbow chaser sketch on 1 of the 2 strips (of 54 leds each) connected to Ethernet cable #1 and a chasing white strobe on the on 1 of the 2 strips connected to Ethernet cable #2. Can something like this run simultaneously on this set up or does the Octo board only flows for a single program on all led strips?

When you call leds.show(), all the LEDs update. So you have to work within that limitation.

Of course, you can just change only some of the pixels and use leds.show(). The ones you didn't change will just be updated to the same setting.

To run 2 animations simultaneously, you'll need to structure your code do both them both. For example:

Code:
elapsedMillis frametime;

void loop() {
  next_frame_of_animation1();

  next_frame_of_animation2();

  while (frametime < 40) ; //wait: 40ms = 25 Hz frame rate
  frametime -= 40;

  leds.show();
}

Then if you can create you animations as 2 functions which draw the next frame, and both expect the same frame rate, this becomes pretty easy. But writing animations this way does require adjusting your thinking from the simpler examples where you just put a delay() inside the animation code itself. This requires calling all the leds.setPixel() for the next frame, and then return to loop() without any delay.
 
Hi Paul,

I'm tried to paste the code you just send to a place inside the original code below but nothing worked: Where does this code fit inside the original sketch below: For me to understand the difference could you please paste it to the right location so I can see, thanks. And is there a place where I can find some programable LED sketches and codes to try?

Below is the original code from the rainbow sketch:

/* OctoWS2811 Rainbow.ino - Rainbow Shifting Test
http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
Copyright (c) 2013 Paul Stoffregen, PJRC.COM, LLC


Required Connections
--------------------
pin 2: LED Strip #1 OctoWS2811 drives 8 LED Strips.
pin 14: LED strip #2 All 8 are the same length.
pin 7: LED strip #3
pin 8: LED strip #4 A 100 ohm resistor should used
pin 6: LED strip #5 between each Teensy pin and the
pin 20: LED strip #6 wire to the LED strip, to minimize
pin 21: LED strip #7 high frequency ringining & noise.
pin 5: LED strip #8
pin 15 & 16 - Connect together, but do not use
pin 4 - Do not use
pin 3 - Do not use as PWM. Normal use is ok.
pin 1 - Output indicating CPU usage, monitor with an oscilloscope,
logic analyzer or even an LED (brighter = CPU busier)
*/

#include <OctoWS2811.h>

const int ledsPerStrip = 54;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

const int config = WS2811_GRB | WS2811_800kHz;

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

int rainbowColors[180];


void setup() {
pinMode(1, OUTPUT);
digitalWrite(1, HIGH);
for (int i=0; i<140; i++) {
int hue = i * 12;
int saturation = 60;
int lightness = 5;
// pre-compute the 180 rainbow colors
rainbowColors = makeColor(hue, saturation, lightness);
}
digitalWrite(1, LOW);
leds.begin();
}


void loop() {
rainbow(10, 2500);
}


// phaseShift is the shift between each row. phaseShift=0
// causes all rows to show the same colors moving together.
// phaseShift=180 causes each row to be the opposite colors
// as the previous.
//
// cycleTime is the number of milliseconds to shift through
// the entire 360 degrees of the color wheel:
// Red -> Orange -> Yellow -> Green -> Blue -> Violet -> Red
//
void rainbow(int phaseShift, int cycleTime)
{
int color, x, y, offset, wait;
int white = makeColor(0, 0, 100);

wait = cycleTime * 1000 / ledsPerStrip;
for (color=0; color < 180; color++) {
digitalWrite(1, HIGH);
for (x=0; x < ledsPerStrip; x++) {
for (y=0; y < 8; y++) {
int index = (color + x + y*phaseShift/2) % 180;
leds.setPixel(x + y*ledsPerStrip, rainbowColors[index]);
}
}
leds.show();
digitalWrite(1, LOW);
delayMicroseconds(wait);
}
}
 
The key part is
Code:
for (x=0; x < ledsPerStrip; x++) {
for (y=0; y < 8; y++) {
int index = (color + x + y*phaseShift/2) % 180;
leds.setPixel(x + y*ledsPerStrip, rainbowColors[index]);
The leds.setPixel is where the pixels are updated, with the uint32_t value found in the rainbowColours array.

So a first step is just to make that line:
leds.setPixel(x + y*ledsPerStrip, x+y*256);
Which if I'm remembering the code should give you a two colour gradient across the matrix

Then try writing your own routine to return colours using makeColor(hue, saturation, lightness); in various mixes using values 0-256. Obviously anything that trends towards lightness 0 or saturation 256 will give boring results.

Then it's time to implement your seperate strands routine. Lots of ways to do that, but I'd suggest either a set of ifs checking y==0/1/2 etc or more elegantly a case https://www.arduino.cc/en/Reference/SwitchCase

Regardless suggest keeping the current pair of For loops, even if you skip some pixels since it avoids any <0 or greater than maxpixels values being used which will hard crash this code. Also makes it less likely a pattern will overflow onto another line, or some of the other failure modes of multiple code segments writing pixels at will.
 
Status
Not open for further replies.
Back
Top