6
\$\begingroup\$

I've recently purchased SparkFun's starter arduino kit, which comes with a 4-legged RGB LED. If I understand correctly, this RGB LED should be able to access the full range of RGB colors, with 255 values on each red, green, and blue.

I've wired up my arduino+breadboard with 330 ohm resistors inbetween power and each of the LEDs (I know, the red needs a bigger resistor. Sparkfun only gave me 330 ohm...). I've written a program that gives me three slider inputs, so that I can easily choose the 0-255 value for each LED. Programmatically this seems to work fine, but I'm having some trouble with the actual output to the LED.

It seems that both red and blue only have two settings available - on and off. As soon as I pass 150 for each color it turns on, anything below that and it is off. Moving the value beween 150 and 255 does not change the intensity of the color - it stays exactly the same.

The odd thing, is that the intensity works perfectly for green. Starting at 0, as I increase the intensity slider the green gets brighter and brighter.

Why do my red and blue colors not work the same as the green slider?

Update 1:
I apologize for my ignorance. I don't know what a PWM is. The code is written in Node.js, and utilizes duino for interacting with the board. You can view my code on github.

Update 2: I switched the power inputs for blue and green, and sure enough the blue now works correctly while the green does not. Still not sure what this means - I will continue to double and triple check that my resistors are snug, but I'm not sure what else. Sorry for my illiteracy in electronics.

\$\endgroup\$
  • 1
    \$\begingroup\$ First switch the Red or Blue with the Green. This will determine where the problem lies. Second, post your code and how it is connected so we can see if you're not using PWM or some other issue. \$\endgroup\$ – Garrett Fogerlie Dec 2 '12 at 21:21
  • \$\begingroup\$ What is the output of the code you wrote? Is it adjusting a PWM output? \$\endgroup\$ – Samuel Dec 2 '12 at 21:21
  • \$\begingroup\$ @GarrettFogerlie Updated the question. Switching the power inputs for the blue and green makes the blue work, and the green break. What would that indicate? \$\endgroup\$ – jwegner Dec 2 '12 at 21:35
  • \$\begingroup\$ OK, I'm getting closer. I moved my LEDs to 3, 5, and 6, which my board indicates are all Digital PWM outputs. However, now my port 5 in my code seems to operator port 3 on the board, and I can't get any of the other ones to work.. What am I doing now? \$\endgroup\$ – jwegner Dec 2 '12 at 21:39
  • \$\begingroup\$ Got it. My IDE wasn't saving the files. Heh. @GarrettFogerlie, if you make an answer telling me it's a PWM issue I'll accept your answer. Thanks! \$\endgroup\$ – jwegner Dec 2 '12 at 21:48
2
\$\begingroup\$

The problem ended up being a PWM issue. (It was solved in the comments, however I've posted the following to help future readers of this.)

First switch the Red or Blue with the Green. This will determine where the problem lies. If the Red or Blue still doesn't work then the problem is with the LED (very unlikely) or somewhere in the connection. Otherwise it is a software problem, like incorrect use of PWM.

Helpful links:

\$\endgroup\$

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.