Cathode and anode wiring

Trying make a daft punk helmet. I’ve soldering some LEDs up already 4 pin anode I can get them to flash different colours but the led will not turn off will go back to white. I just tried a cathode bulb and works fine. With the polarity switched.
Coding done via chat gtp. I’ll post pic of wiring cathode is anode not just reversed thanks

Powered by 6v and earth is from earth esp32

Welcome!

No idea what a "cathode bulb" is, please post a link to its technical information and what is your question?

Cathode led common is earth and anode led common is positive. With common led negative to negative and resistors to positive. I can get led to lights change colours and led will turn off.

If it try with anode led. Which opposite. Common to power and resistors to negative they light up but led don’t turn off

If that makes more sense

A tri colored LED can be what we call common cathode or common anode. There are color pickers but I can tell you that when a tri color LED is white all three colors of Red, Green and Blue are full on.

The below is an example of common anode. The image also depicts 3 ea of R, G, and B.

Note the applied polarity.

You do not want to reverse bias a LED. Exceed the reverse bias (LED connected to reverse polarity) and you kill the LED. Kill as in dead.

Ron

Hi, @lflower89
Welcome to the forum.

Please post us the code you are using?
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
What Arduino are you using?

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

#define RED_PIN 5
#define GREEN_PIN 18
#define BLUE_PIN 21

void setup() {
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);

// Turn everything OFF (because anode = HIGH is off)
digitalWrite(RED_PIN, HIGH);
digitalWrite(GREEN_PIN, HIGH);
digitalWrite(BLUE_PIN, HIGH);
}

void loop() {

// :red_circle: RED ON
digitalWrite(RED_PIN, LOW);
digitalWrite(GREEN_PIN, HIGH);
digitalWrite(BLUE_PIN, HIGH);
delay(500);

// OFF
digitalWrite(RED_PIN, HIGH);
delay(200);

// :green_circle: GREEN ON
digitalWrite(RED_PIN, HIGH);
digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, HIGH);
delay(500);

// OFF
digitalWrite(GREEN_PIN, HIGH);
delay(200);

// :blue_circle: BLUE ON
digitalWrite(RED_PIN, HIGH);
digitalWrite(GREEN_PIN, HIGH);
digitalWrite(BLUE_PIN, LOW);
delay(500);

// OFF
digitalWrite(BLUE_PIN, HIGH);
delay(200);
}

This is for anode led

Thanks Luke Use code tags to format code for the forum

#define RED_PIN 5
#define GREEN_PIN 18
#define BLUE_PIN 21

void setup() {
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);

// Turn everything OFF
digitalWrite(RED_PIN, LOW);
digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, LOW);
}

void loop() {

// :red_circle: RED ON
digitalWrite(RED_PIN, HIGH);
digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, LOW);
delay(500);

// OFF
digitalWrite(RED_PIN, LOW);
delay(200);

// :green_circle: GREEN ON
digitalWrite(RED_PIN, LOW);
digitalWrite(GREEN_PIN, HIGH);
digitalWrite(BLUE_PIN, LOW);
delay(500);

// OFF
digitalWrite(GREEN_PIN, LOW);
delay(200);

// :blue_circle: BLUE ON
digitalWrite(RED_PIN, LOW);
digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, HIGH);
delay(500);

// OFF
digitalWrite(BLUE_PIN, LOW);
delay(200);
}

And for the cathode bulb I’ve reversed the common with no issues. Led turns on and off.

No, No, No. The following is for the common Anode example.

Your wiring has + to the LED anode and the LED cathodes via resistors to GND, with the digital outputs connecting at the junction of the LED and resistor. This is wrong, and will quickly damage your Arduino.

Connect the resistors to the digital outputs INSTEAD of connecting them to GND. The current path should be from + through diode, then through resistor to digital output.

Could you draw quick diagram if possible on a breadboard

Thanks Luke

All colours are lighting up but led will not turn off completely bright green to lower brightness

IMG_6809|375x500

#define GREEN_PIN 18

void setup() {
pinMode(GREEN_PIN, OUTPUT);

// Start OFF
digitalWrite(GREEN_PIN, HIGH);
}

void loop() {

// :green_circle: GREEN ON
digitalWrite(GREEN_PIN, LOW);
delay(500);

// :green_circle: GREEN OFF
digitalWrite(GREEN_PIN, HIGH);
delay(500);
}

Hi, @lflower89

This should help.

Tom.... :smiley: :+1: :coffee: :australia:

  • Learn how a gender changer header works.

All I’ve got on me at the moment sorry but is the wiring right way around ? And the code ok

Is this right. Sorry just trying learn what everything means as I go also. Don’t wanna buy more LEDs for sake my wiring wrong way around :see_no_evil_monkey:


Please edit your posts that contain code, select all code and click the <CODE/> button. Next save your post.

This will apply code which will make the code easier to read and easier to copy and the forum software will display it correctly.

Thanks.

Pictures for the nkotb...

@lflower89
That is your entire problem right there.
For the common anode LED to turn off the cathode and anode must both be at 6V and you can't do that with a 3.3V ESP.
You have 6V on anode and 3.3V on cathode, so you still have 2.7V across the LED, not 0V so it lights up dim

Hi, @lflower89

Can you post some images of your complete project, the ESP32 connections especially.

Have you tried another output pin, other than 18?

Thanks... Tom.... :smiley: :+1: :coffee: :australia: