LED supply issue from Arduino Uno

I have 2 programs that do basicly the same thing. However when I'm calling my diode to blink, it blinks at full brightness on one program but not on the other (just a bit). What might be the cause?

The difference in the programs :slight_smile:

Maybe you forgot to set the pin to output in one of the programs.

sterretje:
The difference in the programs :slight_smile:

Maybe you forgot to set the pin to output in one of the programs.

You made me feel dumb :v Yeah it was it! Im just suprised that it worked anyway but less efficiently. Anyway Thanks You ^^

One more question. Does it change anything if I dont set a pin as an input for digital pins?

Hi Skiermaxhtc, No matter how long we do this stuff, everyone makes little errors from time to time - it’s all good learning.

Re your digital pins, they default to input so there’s no problem not declaring them, however a lot of people will explicitly declare them to avoid any doubt. It’s a habit to explicitly declare pins and knowingly set the registers how you want them.

Steve

If you want to make sure that they are input

void setup()
{
  for(byte pin=2;pin<=13;pin++)
  {
    pinMode(pinCnt, INPUT);
  }

  normal setup stuff here
}

For a 328P based board, this will set all digital pins to INPUT. It skips the two pins used for serial communication.

Skiermaxhtc:
Im just suprised that it worked anyway but less efficiently.

This is because when the pin is in the default INPUT mode, setting it HIGH enables the internal pull up resistor and setting it LOW disables the pull up resistor. So the result was the equivalent of you using a ~30k ohm current limiting resistor on the LED, resulting in a very low brightness.