Hello,
I am new to programming in c and electronic. I have many 74hc595 and rgb 4 lead leds. I have been looking high and low for a basic example of controlling rgb leds.
I have found examples of running through an array, making leds flash but not controlling coloring.
I would like to start with one 74hc595 and a couple RGB led color control colors example.
I am a very visual person and need to see the wire layout and coding to control each led lead.
I would like to start with one 74hc595 and a couple RGB led color control colors example.
If you are just starting out, just experiment with driving the RGB led from the Arduino directly( with series limiting resistors of course) then progress to the 595.
thanks,
I do understand that much. then I throw a 595 and a couple more RGB leds; I could not control the colors.
What I got out of this code: You set the pins to the color and pass into the function to generate the result. I know with the 595, I am dealing with arrays. I am banging my head over the control of each color.
Think of an RGB LED as three separate LEDs. You can turn any of the pure colors on with a single LED. When you want more interesting colors, you need to blend the three colors together. The code example you are using is blending the colors together using PWM. Each LED is turned on and off rapidly so that the color you see is a blend.
The pins that are chosen in the example are important. They are capable of Pulse Width Modulation (PWM). If you don't understand PWM, look it up now.
When you add a component in between the Arduino and the RGB LED, you need to preserve the on/off cycling to keep the color. You have to continually write the shift register to turn the LEDs on and off in the right proportion to keep the color blend.
Consider the line
setColor(0x4B, 0x0, 0x82); // indigo
Red and Blue are blended together with a proportion of 0x4B to 0x82 with 255 being on all the time and 0 (like Green here) being off all the time.
There are specialty ICs for driving LEDs instead of a 595 depending on your configuration. Common anode or common cathode?
Hi, the easiest to use in my opinion is the ws2812b led. This has its own shift registers and pwm for colour mixing built in to the led itself. You can connect large numbers if these leds in a string to a single Arduino output. The leds are available in strips and on tiny individual pcbs. They are also known as "neopixels". There are a couple of libraries available to make them even easier to use.
Unfortunately the 74hc595 doesn't have hardware PWM-capabilities, making it harder to dim leds. Another disadvantage is that it can only handle 70mA, leaving only a few mA per led.
But... PWM using 595-chips can be done in software as well.
hello all,
I'm so new, I just learned that there is a difference between RGB leds - anode and cathode. I then learned that I have been using cathode with anode wire layout. I can not find any examples using cathode rgb leds with 7hc595 or the tlc5940nt I just received.