So currently I am using a sketch that uses two pots to call on

(Evan Bruno) #1

So currently I am using a sketch that uses two pots to call on hue and brightness. I have successfully created groups of leds that can be controlled with a single line of code, but can I render the hue of a single group to be a step or two lower than the other group(s)? So when I turn the hue pot I get a mix of different colors based on the groups created?

(JP Roy) #2

Of course you can… Why wouldn’t you ??

Upload your code to pastebin or gist if you want a more specific answer.

(Mike Thornbury) #3

Do some sort of mathematical calculation on the variable you use to pass the pot value for your second set of LEDs.

For example, if you pass POTVAL to the first set, pass (POTVAL*.75) to the second and they will be a quarter ‘different’, depending on what value you are changing (H, S, V or brightness)

It doesn’t have to be a percentage, you could just subtract a fixed or variable number, or a log or random, depending on what you are trying to achieve.

Post your sketch on pastebin nc we can have a look.

(Evan Bruno) #4

That is both codes that im trying to implement.

(JP Roy) #5

First thing you need to do is to combine the 2 sketches into 1.

You cannot have 2 setup() or 2 loop()…

So copy info from one into the other and delete any duplicated stuff.

You will have to do the same with the #define’s and the global variable declaration.

Just cut and paste from one to the other and again delete any duplicated stuff.

When you get the single sketch to compile and do something useful then it is quite simple to get what you want.

If you get can’t get there… come back and I will help more…

(JP Roy) #6

Ok just a few hints…

  1. You must of course keep a copy of the function… void checkKnobs(){
    in your single sketch

  2. Try the following in your main loop…

for (int i = 0; i < NUM_RAILA; i++)
leds[raila[i]] = CHSV(hue,255,brightness);

for (int i = 0; i < NUM_RAILB; i++)
leds[railb[i]] = CHSV(hue+85,255,brightness);

for (int i = 0; i < NUM_CAPS; i++)
leds[caps[i]] = HSV(hue+170,255,brightness);

Of course you can change the values 85 and/or 170 to your satisfaction!

(Mike Thornbury) #7

I will leave you in JP’s (much more capable) hands…

(Evan Bruno) #8

@JP_Roy Yeah, that all makes total sense. Now the next question is if I set one of the groups to have a positive 180, as I turn the potentiometer up will it pass 255 and go back to one? If not is there a way to do that? Otherwise one group will cap out before the potentiometer reaches its full throw.

(JP Roy) #9

@Evan_Bruno as you pass 255 it will go to 0 and continue up from there. So no, the value will not cap out at 255.

Best way is just try it and you will see…

(JP Roy) #10

One thing to remember about using that pot value for hue. Hue is a value that has a range of 0-255.

Hue of 0 is actually red. Going up from that gives you hues of 1, 2, 3… They are still mostly red but progressively going towards orange.

Going backwards from 0 gives you 255, 254, 253… they are also very much red but going towards pink and purple so will give you a very smooth, almost unnoticeable transition.