# Candy Cane pattern for LED Strip Lights

**URL:** <https://forum.electromage.com/t/candy-cane-pattern-for-led-strip-lights/1806>\
**Category:** Uncategorized\
**Created:** [December 7, 2021, 3:40am UTC](https://forum.electromage.com/t/candy-cane-pattern-for-led-strip-lights/1806 "2021-12-07T03:40:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jeff](https://forum.electromage.com/user_avatar/forum.electromage.com/jeff/32/3473_2.png) [@jeff](https://forum.electromage.com/u/jeff)\
**Post date:** [December 7, 2021, 6:03am UTC](https://forum.electromage.com/t/candy-cane-pattern-for-led-strip-lights/1806/2 "2021-12-07T06:03:49Z")

</div>

Hi @Jsharkbite!

I’ll also help you with your code, but first I wanted to let you know about a pattern I made to do stuff exactly like this using Pixelbalze’s built-in UI controls.

First, grab the “Custom sequences” pattern. It’s currently near the bottom of the first page in the [pattern library](https://electromage.com/patterns).

Then configure it for these settings:

 ![Railing 2021-12-06 21-40-42](https://forum.electromage.com/uploads/default/original/2X/0/01a3c2090bab0a33e886f4b9f57cf345587e341f.png)

Viola:

 ![IMG_0589 copy](https://forum.electromage.com/uploads/default/original/2X/1/1df74bdd622e6dbe529ef881b8fd29b3dbc6d36a.jpeg)  
_The ones that look purple in this pic are actually fully off_

OK, but what fun is Pixelblaze if we’re not relearning a little math that we all used to know once upon a time? Let’s figure out how to make your code make index 1, 5, 9, etc white, and 3, 7, 11 etc all red. You’re very close.

It all comes down to this: What do 1, 5, 9, 13 etc all have in common?

Remember the idea of a reminder from math? If we divide all those numbers above by 4, the fractional part will be `.25`. But with integer math in a system with a decimal point, like Pixelblaze, we can instead say that when you divide any of those numbers by 4, the remainder is 1. For example, 13 is made up of 3 groups of 4, and then 1 more. In Pixelblaze, we get the remainder by using the percent sign operator: `%`.

```javascript
( 9 % 4 == 1) // This is a true condition
( 10 % 4 == 2) // Also true
( 12 % 4 == 0) // True
( 13 % 4 == 3) // False

```

So, armed with this, I think you could add just a few characters to your code and get what you want!

---

_[View the full topic](https://forum.electromage.com/t/candy-cane-pattern-for-led-strip-lights/1806)._
