I have an RGB LED strip which I want to control with my arduino uno, everything works fine, except for the green LEDs. They cannot be dimmed to less than 50%, because they will simply turn off.

I have this test code in my setup:

Serial.write("dimming green test started");
for(int x = 255; x > 0; x--) {
    Serial.write(" - g:");
  Serial.write("dimming green test done");

And the green LEDs are fully turned on in the beginning, and at about 127, the just turn off. All the other colors are perfectly dimmable. I checked the energy usage, and green does only use a little more than the other colors, so that's not the problem.

Are green LEDs not dimmable? Or is this just an optical effect?

(I use a setup very similar to this one with one difference: but only use 5V, because my LED strip only needs 5V) setup

  • 1
    switch connections at arduino. swap pin 4 and 7 ... does the problem move to red color?
    – jsotola
    Feb 27 '18 at 17:43
  • 1
    the pins marked with ~ are the PWM pins ... use those
    – jsotola
    Feb 27 '18 at 17:48
  • so why does blue and red work :p Feb 27 '18 at 22:42
  • I used pins 5-7 (so the image was not exactly correct)
    – Finni
    Mar 4 '18 at 14:06

analogWrite only works on pins that support PWM. Those are the pins with the ~ next to it.

On no-PWM pins, analogWrite will set the pin to LOW, for all values lower than 128, and HIGH for all the higher values. Which is what you are experiencing.

  • interestingly, none of the 3 pins chosen by the OP - 2,4 and 7 - have that ~ symbol in the image in the question! Feb 27 '18 at 22:39
  • @JaromandaX the OP said the image was from a similar project, so I’m not assuming he used those exact pins.
    – Gerben
    Feb 28 '18 at 12:04
  • with one difference - well, there's three connections to LED's, but only one fails to work ... must be at least two differences between actual wiring and what OP shows in the question :p Feb 28 '18 at 12:24
  • I used pins 5-7, so only one of them was not PWM
    – Finni
    Mar 4 '18 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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