Multisegment on a larger project?

Hello fellow PB enthusiasts!

I’m currently working on an art piece where I need to be able to run multiple patterns, like with the Multisegment set up, but with specific segment lengths and it just keeps giving me the “array out of bounds” error, when it should be functioning.

I’m using a v3 with the sensor expansion and the total pixel count is 248. As soon as I add the last segment of 156 at the end, that pops the error. I’m thinking it’s asking too much of the controller? Or I could just be stupid, I’ve never been the best at coding. Going from @zranger1 's explanation in here a few years ago, I put it together like this:

SetSegState(1,true) ; // true = on, false = off
SetSegEffect(1,1) // sets the animation for the segment. (0 is none)
SetSegHSV(1,1,1,1); // sets the initial color for the segment (segment number,h,s,v)
SetSegSpeed(1,1); // sets initial speed for animations (,1)
SetSegSize(1,49) // (,)


SetSegState(2,true) ; // true = on, false = off
SetSegEffect(2,2) // sets the animation for the segment. (0 is none)
SetSegHSV(2,4,4,4); // sets the initial color for the segment (segment number,h,s,v)
SetSegSpeed(2,1); // sets initial speed for animations (,1)
SetSegSize(2,31) // (,)


SetSegState(3,true) ; // true = on, false = off
SetSegEffect(3,2) // sets the animation for the segment. (0 is none)
SetSegHSV(3,4,1,4); // sets the initial color for the segment (segment number,h,s,v)
SetSegSpeed(3,1); // sets initial speed for animations (,1)
SetSegSize(3,12) // (,)


SetSegState(4,true) ; // true = on, false = off
SetSegEffect(4,4) // sets the animation for the segment. (0 is none)
SetSegHSV(4,5,5,5); // sets the initial color for the segment (segment number,h,s,v)
SetSegSpeed(4,1); // sets initial speed for animations (,1)
SetSegSize(4,156) // (,)

Any guidance would be very appreciated! You guys rock…

Hi and welcome!
This is complicated, there’s a lot to unpack and I’m still recovering from the gift of pneumonia I got at Coachella – not a lot of endurance here, so briefer than usual. Apologies if tone seems off or if something doesn’t make sense.

First thing, try using the code block below to initialize your lights. It creates 4 differently colored solid segments of the sizes you specified.

A few programming things to note:

  • segment numbering, like most Pixelblaze array indexing, is zero-based. The first segment will be segment zero
  • There is no SetSegHSV(). It’s called SetSegHSB(), named back when I was more willing to be picky about silly semantics. If I called it …HSV() in a forum post, I was wrong about the code (but we normally call the color model HSV in pattern land.)
  • colors in Pixelblaze land are all n the range 0.0 - 1.0. Anything larger than that just wraps. HSV hues are % of complete circle) rather than in degrees. So 0.0 is red, 0.333 is green, 0.6667 is blue, etc.

I look forward to seeing what you make! If you have more questions, please ask, and I or somebody else will help you out!

SetSegState(0,true) ; // true = on, false = off
SetSegEffect(0,0) // sets the animation for the segment. (0 is none)
SetSegHSB(0,0,1,1); // sets the initial color for the segment (segment number,h,s,v)
SetSegSpeed(0,1); // sets initial speed for animations (,1)
SetSegSize(0,49) // (,)

SetSegState(1,true) ; // true = on, false = off
SetSegEffect(1,0) // sets the animation for the segment. (0 is none)
SetSegHSB(1,0.22,1,1); // sets the initial color for the segment (segment number,h,s,v)
SetSegSpeed(1,1); // sets initial speed for animations (,1)
SetSegSize(1,31) // (,)

SetSegState(2,true) ; // true = on, false = off
SetSegEffect(2,0) // sets the animation for the segment. (0 is none)
SetSegHSB(2,0.4,1,1); // sets the initial color for the segment (segment number,h,s,v)
SetSegSpeed(2,1); // sets initial speed for animations (,1)
SetSegSize(2,12) // (,)

SetSegState(3,true) ; // true = on, false = off
SetSegEffect(3,0) // sets the animation for the segment. (0 is none)
SetSegHSB(3,0.6667,1,1); // sets the initial color for the segment (segment number,h,s,v)
SetSegSpeed(3,1); // sets initial speed for animations (,1)
SetSegSize(3,156) // (,)

Oh, I just remembered – it might actually be SetSegHSV() in the version of multisegment you have. My (somewhat ancient) personal version isn’t the one that ships with new Pixelblazes.

The shipping version has expanded comments and has been brought up to modern code standards. Sorry for any confusion on this point. Whichever of SetSegHSV() or SetSegHSB() works on your Pixelblaze is the right one to use!