Skip to content
GyroGearloose edited this page Jun 27, 2015 · 11 revisions

###Welcome to the FastLED_Rotary_Encoder wiki!

Rotary Encoders are great if you want precise settings.

Compared to potentiometers they have the benefit, that the assignment of a value is much faster. An analogRead of a pot takes about 110µsec and during this time the program cannot proceed. Rotary Encoder counts are triggered with Interrupts. Make sure that the Interrupt routine is as short as possible, otherwise you will loose the time benefit.

There are so many ways to do this: http://playground.arduino.cc/Main/RotaryEncoders

Another interesting feature might be that also the encoder signal of a DC motor can be used (e.g. the faster the motor turns the brighter the animation gets).


This sketch shows the basics what you need. The encoder shows values from 0..10. Only when the knob is turned and the value is changed, it triggers a new effect. Encoder_Reading_w_Trigger_on_Change.ino


The other sketch uses the Fire2012 from FastLED 3.1 .

The encoder reading is directly assigned to the Hue and makes use of a great feature of the FastLED lib: Hue is limited from 0..255. So there is no need to limit the encoder readings.

If don't want to make so many turns to scroll through the color palette just multiply the encoder reading by a suitable value between 2..128 and enjoy. Fire2012_control_color_w_Rotary_Encoder.ino


###Restrictions:

If you are using ws2811/neopixel style LEDs FastLED has to disable interrupts while writing out led data, and there really isn't any way around that.

Your options include:

  • switching to 4 wire leds like dotstars/apa102 which doesn't need interrupts disabled to write out data
  • a platform like the teensy3.1 where some interrupt handling can happen while writing out led data
  • change your data protocol to be an explicit request/response setup so you only ask for and read data while led data is not being written out.

Kudos to Daniel Garcia

Clone this wiki locally