Arduino, WS2812b (122), encoder KY040.

Arduino, WS2812b (122), encoder KY040. Now looking for the right code for changing color and brightness with 1 encoder. No-click = color change, on-click=brightness. Anyone having some code around to finish this thing?

I’d use a pot for brightness and an encoder for something more exotic, such as changing modes.

Anyways, I came across this a while back, but haven’t tried it out yet.

http://pastebin.com/S8JAnFkh

What do you have so far @Rowin_Grunder ?

If you don’t have anything yet, how are you thinking you’re going to attack this project?

Usefull library for use with encoder.
https://github.com/0xPIT/encoder (this is handy because of the library uses “acceleration support” which makes it handy to scrolll trough colors and brightness fast/slow.)

But how i would tackle this project is to need a script where i can say that 1 click of the encoder is some sort of switch like else/if.

– led light is powered off
– led light is turned on (opens latest brightness 50% and color orange stored)
0 - encoder not clicked - brightness parameter changes 50% -> 25% via twisting encoder knob)
1 - encoder is clicked - color parameter (changes orange color -> red color)
0 - encoder is clicked - brightness parameter (calls latest brightness 25% and changes it to 75% via twisting encoder knob)
1 - encoder is clicked - color parameter (calls orange color changes to -> blue
– led light is powered off
– led light is turned on (and opens latest brightness 75% and color blue)

this is how i want my led light to work.

So you’d like fixed colors when you click the switch rather than using the rotary encoder to change colors when not adjusting brightness?

oh sorry, no. all leds (for now) same color and can be changed with the rotary encoder. when i click the switch the rotary encoder changes its behaviour into changing the brightness of the leds.

thanks! would you do me a favor and share your code so i can check what i need?

I asked a similar question not so long ago.
https://plus.google.com/+AnthonyOllerton/posts/QPG9Fex3VWD
Just had a look for the code and it appears i haven’t saved it.
From what i remember though i was using this library with no interrupts.
http://www.pjrc.com/teensy/td_libs_Encoder.html