Hey!
I'm new to arduino and anything electronics related.
I'm trying to power an RGB LED using an external power supply. However, it is incorrectly blinking white when I run my arduino program. Could someone help me with this issue please?
tinkercad: https://www.tinkercad.com/things/cPLfcJkUcbp-rgbled?sharecode=PCgaescJKesFBkYhrWJ2Tzfw-JE4VooqBLoayVkjDa4
code:
// C++ code
//
const byte R_PIN = 9;
const byte B_PIN = 10;
const byte G_PIN = 11;
void setup()
{
pinMode(R_PIN, OUTPUT);
pinMode(B_PIN, OUTPUT);
pinMode(G_PIN, OUTPUT);
}
void loop()
{
analogWrite(G_PIN, 255);
delay(1000);
analogWrite(G_PIN, 0);
delay(1000);
analogWrite(B_PIN, 255);
delay(1000);
analogWrite(B_PIN, 0);
delay(1000);
}
sketch:
Thanks
Please post your full sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
It is also helpful to post error messages in code tags as it makes it easier to scroll through them and copy them for examination
Search the web for "arduino rgb led circuit diagram", yours is incorrect.
Your LED is wired wrong, it will always be white (ALL leds lit)
@tnyhynh It's actually wrong at least two ways.
Looking at the "schematic" you're controlling all three LEDs at the same time using the common pin of the RGB LED; it does not matter which transistor / FET is on, all three LEDs will be on.
If this is a standard RGB LED (max current roughly 20 mA per colour) you do not need the transistors / FETs.
It is a regular RGB LED (max of 20mA per color). I know the transistors are not needed and I can drive the LED directly from the Arduino pins. However, how could I possibly try to include these transistors in the schematic? Just trying stuff out.