Thursday 10 December 2015

arduino - RGB LED - Set intensity on Red and Blue


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.



Answer



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:



No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...