In this tutorial, We'll use an RGB LED (RGB means Red, Green, Blue) to flash through a sequence of colours and study the distinction between a typical Anode and Common Cathode RGB LED structure.
You’ll need the next components. Importantly, There's two types of RGB LEDs—described below—so you should definitely select which form of RGB LED you're applying as it will eventually have an impact on the way you configure your circuit. But don’t stress, we’ll walk as a result of equally RGB LED styles.
Typical Anode vs. Typical Cathode
Although able to exhibiting Countless shade combinations, RGB LEDs are actually fairly simple; they contain 3 independent LEDs in one package: purple, environmentally friendly, and blue. Importantly but relatively confusingly, There's two RGB LED models—the Prevalent Anode as well as the Prevalent Cathode—which vary in the leg shared among the three embedded LEDs.
With the Prevalent Anode, the three embedded LEDs share the anode leg. To regulate the RGB LED’s coloration, you must hook up the anode to the upper voltage resource and join the pink, green, and blue legs to reduce voltage stages (e.g., ground). By way of example, having a 5V voltage supply connected to the frequent anode leg, placing the 3 other legs (pink, green, blue) to 5V would, fairly counterintuively, switch from the LED.
In contrast, the Widespread Cathode will work considerably more like a standard LED (e.g., similar to the crimson LED from our prior classes). Below, all three embedded LEDs share the cathode leg. So, you push Every specific shade leg with a greater voltage source.
How am i able to convey to if I've a Common Anode or Cathode RGB LED?
You can't tell whether or not you've got a Frequent Anode or Prevalent Cathode RGB LED by Visible inspection. As a substitute, seek advice from the provider Web page, the datasheet, or experiment While using the LED you (try to remember, diodes only work in one path so provided that you consist of your present-day limiting resistors, you ought to be great!).
We’re likely to get started with a standard Cathode circuit + code as it’s extra intuitive (and similar to our purple LED tutorials) prior to masking the Prevalent Anode Model.
Producing the circuit
With a typical Cathode layout, the 2nd leg has to be connected to the GND pin along with the 1st (purple), third (blue), and 4th (environmentally friendly) legs ought to hook up with digital I/O pins (don’t forget about rgb LED arduino a latest limiting resistor for every). We might have applied any digital I/O pins; having said that, we chose Pins 6, five, and 3 for purple, blue, and green respectively (these pins aid PWM and therefore, we’ll have the capacity to use precisely the same circuit for our subsequent tutorial on cross-fading colors with RGB LEDs).