I'm doing a project for university and I am struggling to code and set up a rotary encoder that can control hot-cold variations. Much like the idea of communicating temperature selected by turning a dial. I would either like to control a single strip of RGB LEDs or a single bulb (changing and fading between colours at the same time).

I would like to have the dial turn from 0 - 180 degrees and relate to intense blue changing to intense red and all the colours in between as increments.

I have an Arduino Uno.

Thank you!

  • Which part of that are you having a problem with? Reading the rotary encoder or making the LED(s) light up in the right way?
    – Majenko
    Aug 25, 2016 at 22:46
  • The SE format works best asking 1 question and getting 1 answer. And, you'll get a lot more responses here if you give your project a try first. Then, if you get stuck, ask a question about the issue you are having problems with. That said, break your project into two parts. There are plenty of on line web pages regarding rotary encoders. And plenty of on line web pages which talk about RGB LEDs.
    – st2000
    Aug 26, 2016 at 1:53
  • Did you miss to add your source code, components and wiring? Aug 26, 2016 at 13:34
  • 3
    If you want a dial that turns from 0 to 180, is a rotary encoder the best option? Generally this component is used either (a) as a rotational speed sensor; or (b) because we've got used to having seamless rotary controls. A potentiometer would be better suited, and easier to include. Aug 26, 2016 at 19:51
  • 1
    You probably want to use the HUE color scheme instead of RGB and then just map the HUE value to the analog value of a potentiometer.
    – Paul
    Jul 27, 2017 at 14:18

2 Answers 2


Well as I understand you want to use a rotary encoder ? Rotary encoder can turn freely. Which you can read via arduino easily with a library. You can count a number(let's say x) from 0 up to 255, and write that number to one of the color. For the other color write 255-x so when blue is fading down the red is increasing. But I suggest you to use a potentiometer which has a limited turn (about 270 degrees). Connect it to arduino's one of the analog read pins. It will give you a 10 bit value which is between 0-1023 . You can scale this down to 0-255 range with map function. [Example: "x = map(x,0,1023,0,255);" ] after that just follow the same process as before.


http://playground.arduino.cc/Main/RotaryEncoders is where the rotarty encoder libraries are. From there you can use PWM on the outputs as said. There are also some addressable RGB strips/modules that incorporate a driver IC such as adafruit neopixels where you can just write values for colour and brightness to the IC fairly simply, depending on your level of electronics knowledge.

Not the answer you're looking for? Browse other questions tagged or ask your own question.