Flicker Leds with Digital Pin

Sorry I uploaded the wrong image.

I have some Led diodes connected to a 5v supply separate from the power to the Arduino.

Each LED has a 220-ohm resistor on the positive leg.

I want to use the Arduino to flicker the led by having the ground side of the LED go High.

My question is, what is the best way to configure the pin to protect the Arduino

I know it might seem like a dumb question, but I know that the pin can be configured several ways including with internal resistors.

Thank you for any help

Mark

If you configure the pin to be an OUTPUT pin, and set it HIGH, you will create a short circuit, so I don't recommend doing that.

What value is VCC? Why isn't the Arduino supplying the voltage/current to drive the LED?

artistinfla:
I have some LED diodes connected to a 5V supply separate from the power to the Arduino.

What does that mean? What is "a 5V supply separate from the power to the Arduino"? If you have a well regulated 5 V supply, you use that to power the Arduino Nano via its 5 V pin. There are some warnings that you should not use that 5 V supply and connect the Arduino to your USB port at the same time, but it is essential that if you are powering LEDs directly from Arduino pins, the 5 V to which they connect must be the same as the 5 V on the Arduino.

artistinfla:
Each LED has a 220-ohm resistor on the positive leg.

Excellent. Given that, you can drive one such LED from each Arduino output pin, up to ten or so as long as you supply 5 V via the USB port or the 5 V pin. The internal regulator from "Vin" is pretty useless.

artistinfla:
I want to use the Arduino to flicker the led by having the ground side of the LED go High.

My question is, what is the best way to configure the pin to protect the Arduino.

As above - one LED per pin, with a 220 Ohm series resistor, connected to the 5 V terminal.

Your diagram shows the output pin connected to ground. An obvious mistake.

STOP!

In your picture, D2 is shorted to ground. That can damage your Arduino. (It will probably survive, but it's "bad thing" to do and the LED won't turn off.)

Just connect one LED terminal to D2, and the LED will turn-on when D2 is low and off when D2 is high.

There is no need to "configure" the I/0 pin. When you write it becomes an output. Check the Blink Example. ...You can run the Blink Example with your LED with your LED by changing to it to use D2.

DVDdoug:
There is no need to "configure" the I/0 pin. When you write it becomes an output.

What do you mean?

digitalWrite() does not configure a pin as an output. Only pinMode() does that or interestingly, analogWrite.

Pins default to INPUT; if you digitalWrite() a pin HIGH while it is an input, it becomes INPUT_PULLUP and the only current you get is approximately 100 µA which will light a good LED fairly faintly if it is connected from the pin to ground.

Check the Blink Example.

Excellent suggestion! There, the OP will learn to configure the digital pin as an output, as follows.

  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

DVDdoug:
STOP!

In your picture, D2 is shorted to ground.

Yes, I meant to take out the led to ground and only got to the Arduino pin!

Paul__B:
What does that mean? What is "a 5V supply separate from the power to the Arduino"

I have 2 power supplies with common grounds. One is driving the Arduinos and the other the LEDS and motors

Yes the LED Cathode to ground was an error.

Don't bother with Fritzing diagrams as they are a complete waste of time.

If you carefully draw out your circuit by hand, using pencil on paper, you are much more unlikely to make such silly mistakes. Excellent tutorial on reading and writing standard schematic diagrams here: How to Read a Schematic - SparkFun Learn

artistinfla:
I have 2 power supplies with common grounds. One is driving the Arduinos and the other the LEDS and motors

Well, it is as I explained before.

You really should explain why you have two power supplies.

Paul__B:
You really should explain why you have two power supplies.

I want the power to the Arduino with one and not have the motors create noise and not have too much drain that will affect the Arduinos. The power requirements are close to 50A when everything is running at max, though that will most likely never happen and for just the briefest time if and when it does.

I have 18 Arduino modules on this project, 4 MP3 player modules, 4 audio amplifiers, 24 RGB LEDs, 12 IR Sensors, 6 4-digit seven-segment displays, LED displays 48 red LEDs, 48 Green LEDS, 6 dc motors (some large with high current draw under load , 6 servos, 2 WS2812B LED strips and much more.

I realize that one LED only draws 20mA or so but all together I do not want to current drain to affect the Arduinos. Yes, I could use one 50A power supply, but I happen to have 2 30A 12V power supplies and 2 30A 5V regulators. I am Using 12 V because I want to be able to run it off of batteries. I have 2 deep cycle batteries available as well. It will run off of 12v dc from 2 Deep cycle batteries (rated at 850CCA each) or 2 the power supplies. These are items I had available and did not need to purchase

When I wired the project I ran one line for the LEDs. Some will flash, but not all. This was a last minute decision and they were already wired to the 2nd power supply. The wiring harness runs next to the Arduino units that I want to use to flash the LEDs so taking the cathode ground wire seemed like an easy solution for this. I might have been wrong.

I am not sure how the fact that I am using 2 power supplies or why I am using 2 power supplies has anything to do with how to initialize the pin.

The LEDs, numerous, all are getting power from a separate power supply than the Arduino modules. The Arduinos, sound cards, IR sensors, RGB LEDS, and a few other things are using one supply. I would have had the RGB LEDS use a separate one, but I had a good stock of common cathode RGB LEDs so I used them.

I hope that helps to explain why I am using 2 30A power supplies. I could buy a 50A for $40, but I had 2 30A units already. I did the math on the current draw and with everything running is substantial, especially that of the motors.

I did not go into specifics about the entire project because I did not feel it was relevant to my question.

I hope this clarifies why I have 2 power supplies

Paul__B:
it is essential that if you are powering LEDs directly from Arduino pins, the 5 V to which they connect must be the same as the 5 V on the Arduino.

Perhaps this is the crux of the issue. I do not understand why the 5V must be from the same source. Could you elaborate, please.

In re-reading your reply, it seems I am missing something here.

Thank you

No two 5V supplies are really exactly the same. Maybe one is at 5.1V, the other at 4.8V. Now if you connect your LED between the two nominal 5V supplies, you may get odd effects, such as the LED not switching off completely. The motor noise on that 5V line will also easily reach your Arduino.

If you insist on running those LEDs from a separate power supply (which I don't see any good reason to, really), the proper solution is to switch them using a transistor between the LED+resistor and ground. That way the +5V lines can not affect one another.

wvmarle:
the proper solution is to switch them using a transistor between the LED+resistor and ground.

I actually briefly considered that since I use transistors to turn on relays that draw a fair amount of current. I thought it was overkill like using a relay, but after considering the voltage variance, You are correct that it would be the best solution.

thank you

Actually, since the LEDs are connected to a 5 V source, my concern is that if the power to the LEDs is applied and the power to the Arduino is not - for any reason - then the LEDs will "back-power" the Arduino. If the LEDs have a threshold of 2 V and 5 V is applied, then you have 3 V across the 220 Ohm resistor and this could feed up to 10 mA into each protection diode on the Arduino. We understand the safe limit to these diodes is about 1 mA. :astonished:

And don't ask why only one power supply might be operating. :roll_eyes:

Another good point.