Get me started please

Dear coders, i am looking for some help for future projects.
First step i tried a slider as a ‘runner-up’. (no leds when 0, all pixels on when 1)
But i kept on getting errors.
The plan is to later replace the slider by an analog input from a potmeter.

For another project i am looking to use the timing functions.
Pixelcount should be divided into 12 sections and each section should dim-up during its hour. So that at 12AM (as well as at 12PM) all leds are on.
Can someone get me going? I must say that my coding skill is poor, but i guess you got that by now.
Thanks,
Jacob

When asking for help with programming, it helps to show what you did (ideally simplified to the minimum code to express the particular problem), and if you got an error, what was it?

A lot of the time, just explaining the problem in detail, you’ll figure out the answer. (We can it “rubber duck debugging” because talking to a rubber duck can solve your problems.) And if not, you have a good amount of detail for when you ask someone ride for help.

There are lots of scripts that use sliders for reference. A typical start is to read the docs and look through existing scripts. Copy a bit from the examples and adjust it to get what you want.


For splitting pixels into groups, “floor” & “mod” are the functions you’re looking for. (Their names are very not obvious)

floor cuts the fraction off a number - eg 2.5 becomes just 2. (It relates to round which makes 2.5 into 3, and ceiling which always rounds up, so even 2.1 is 3)

mod is the remainder when doing division, eg mod(12,10) is 2. The value will be 0 if the number divides evenly.

numGroups = 12
groupSize = (numPixels / numGroups)

// X is the current pixel number
myGroup = floor(x / groupSize) // integer 0 to numGroups - 1
myFract = mod(x, groupSize) / (groupSize - 1) // myFract is 0.0 to 1.0 depending on place within the group.

(This is not tested code, just to demonstrate floor and mod)

You can try something like setting the color if myGroup == 1, and see only one segment lit up.

1 Like