My LED won't undim :(

*UPDATE: The issue has been solved! *

Thank you to each & every one of you for your help! :smiley: I'm super new to Arduino, and was afraid that my post would get zero help, But I'm so blown away by the amount of support and community here (you guys are so smart!!). I'm super excited to learn more about Arduino, and be apart of such an awesome community!

i coded my LED to dim using:

int yellowPin=9;
int light=5;

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

}

void loop() {
analogWrite(yellowPin,light);  


}

and it worked!

but now i don't know how to undim it.

i've tried this code:

int yellowPin=9;
int light=255;

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

}

void loop() {
analogWrite(yellowPin,light);  


}

but the light still remains dimmed and not at its usual full brightness.

is there a way to fix this?

here's the setup (you can prob see the LED lightly dimmed)

thank you!

Additional Note: I followed this tutorial (Arduino Tutorial 7: Understanding the Arduino Analog Write Command - YouTube) to dim my LED light. The code he used is the code I pasted above in this post. He taught us to dim our lights, but not to undim (so now I'm stuck haha). So I've been trying to undim the LED myself. Whether it's through arduino coding, changing LED/resistor components, connecting to 5V/GND etc. But no luck.

Thanks for reading! Looking forward to learning from you about fixing this.

try putting the led in a digital pin

Hello
Delete **.

Her is a tester for PWM. Try this and see how it goes.

/*
   PWM LED Tester
*/
byte PIN = 9;

void setup()
{
}

void loop()
{
  for (byte a = 0; a < 255; a++)
  {
    analogWrite(PIN, a);
    delay(5);
  }
  for (byte b = 255; b > 0; b--)
  {
    analogWrite(PIN, b);
    delay(5);
  }
}

thanks pulkit! i tried putting it in a digital pin, but still is dim.

Hi,

Did you use pin 9 as in the code?

What is the value of your LED current limit resistor?

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

Hi,
Please run this code and see what happens.

/*
   ON/OFF LED Tester
*/
byte PIN = 9;

void setup()
{
pinMode(9,OUTPUT);
}

void loop()
{
  digitalWrite(PIN,HIGH);
  delay(1000);
  digitalWrite(PIN,LOW);
  delay(1000);
}

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

Hi,
Then try this code;

/*
   PWM LED Tester
*/
byte PIN = 9;

void setup()
{
pinMode(9,OUTPUT);
}

void loop()
{
  for (byte a = 0; a < 255; a++)
  {
    analogWrite(PIN, a);
    delay(5);
  }
  for (byte b = 255; b > 0; b--)
  {
    analogWrite(PIN, b);
    delay(5);
  }
}

thank you tom!

i tried running both codes, and the led still is dim.

but it's flickering on and off due to the delay.

what do you think is happening?

Hi, @flowersontrees

What is the value of your LED current limit resistor?

What are the coloured bands?

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

Same weird things, also Elegoo Mega board, just half a day earlier: https://forum.arduino.cc/t/issues-with-simple-pwm/895147.
What is going on here ?

Elegoo has a download section on its site where the Arduino IDE can be downloaded ! That is terrible ! It is not even the newest version !
Always use the official website: https://www.arduino.cc/en/software.
What else could be wrong ? Bad bootloader ? Wrong pcb ?

Hi,
Strangerer and strangerer.
I await the reply to the series resistor question.

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


I upscaled the provided image. Maybe it can be made out from this.

Connect the LED and its current limiting resistor in series and apply 5V between the two ends with the appropriate ploarity. Does the LED light brightly ?

Please tell us the value, use your multimeter to measure it!
It's up to YOU to provide information, not US to try and work it out for you.

You've mistaken me for OP

Have you confirmed the LED is not in reverse? Have you confirmed it works by connecting it between 5V and GND?

Hi,

I tried likewise, but its one of those horrible type with a very bad body colour.
If it had been the old cream coloured body, even bad colour balance you could still get the value read correctly.

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

With a current limiting resistor in place

It was worth a shot.