How to link 20 850nm LED lights to one power source Arduino Mega

Hi, in advance thank you so much for your help! I'm doing this for a school project and super pressed for time and really confused. I have an Arduino Mega and a bunch of 850nm leds. I need to create patches of LED's (20 per patch) and then somehow take it off the breadboard and place it into a cast. I then need to make 5 patches per cast and have them all sync to one power source. Is this possible? I can use solder, but I don't understand when/where I would need to use it. In addition, I only have 1 breadboard; however, I do have a proshield V3 too. Thank you again!!

These are "regular little" LEDs, right? Do you have a link to the specs?

Generally, each LED needs it's own current-limiting resistor. With 5V and regular LEDs a 220 Ohm resistor usually works.

If you have higher voltage available you can connect 2 or 3 LEDs in series with one "shared" resistor.

I then need to make 5 patches per cast and have them all sync to one power source.

That means they all go on & off together and they are all controlled by the Arduino?

You'll need a Driver Circuit because each Arduino I/O pin can only directly supply 40mA. (You can leave-out the diode since you have a non-inductive load.)

The power supply and driver circuit must be capable of supplying the total current. If you don't have the specs 20mA per LED is a reasonable estimate. They can be rated for more current (and you should allow some safety margin) and the LEDs will use whatever current they need (depending on the resistors, etc.)

5mm LED - Infrared 850nm 50 Degree Viewing Angle is the link to the LEDs I am using. In addition, I want 20 LED's connected to 1 power source, but then able to be removed from the breadboard and attached to an external cast.

How many volts is the power source? Lets start there.

Sorry, what do you mean by that? Like I have a pin connected from the breadboard to the 5V, but I can always convert to a battery or outlet?

Those LEDs are rated for 20mA at 1.6V.

In series, the same current flows through both components but the voltage is divided. With 5V applied we'll have 3.4V across the resistor. From that we can use Ohm's Law to calculate the desired resistor value: 3.4V / 0.02A = 170 Ohms.

180 Ohms is a close standard resistor value so we can use that, and we'll get slightly less than 20mA. Resistance is the resistance to current flow and with higher resistance you get less current (Ohm's Law).

Each LED gets it's own resistor.

Resistor Calculator

. I need to create patches of LED's (20 per patch) and then somehow take it off the breadboard and place it into a cast.

How many "patches" and what's a "cast"?

20 LEDs at 20mA each is 400mA (0.4 Amps).

Here is what I would suggest, assuming you just want the LEDs to be on (or off, with the addition of a power switch between battery a "patch" or several patches).
This would also be easy to implement using LED strips, which are typically set up like this, with 3 LEDs and a current limit resistor per each segment of LED strip.
But if you have LEDs already, then you just need to select a Resistor for the brightness you want. Full 20mA may too bright. Maybe you'll find 10mA is plenty. Do a test.

jchia:
I need to create patches of LED's (20 per patch) and then somehow take it off the breadboard and place it into a cast. I then need to make 5 patches per cast and have them all sync to one power source.

OK, you are doing a poor job of describing your requirement. :astonished:

It actually helps a lot to explain the actual purpose of the project.

In the meantime, let's start with these "patches". Twenty LEDs, do all light up at once or do you need to turn on and off smaller groups? In fact, do you actually need to switch them on and off with the Arduino? Presumably you do or it would be odd to be asking here but you have not made this clear at all.

Five "patches" - do they all turn on and off together or individually? Will you need another five patches somewhere else?

Now what do you have - or intend to use - as a power supply? Please do not mention a Mega 2560; it is not a power supply in any respect and was actually an unnecessarily cumbersome choice for a serious project. So what do you propose to use as a power supply?

Hi, I am new to Arduino and am wondering if I can program my blinking 850nm LEDs to automatically turn off after 30 minutes? If so, how can I program a timer into the code? In addition, will the timer code need to run under my code to make the LEDs blink? Thank you in advance!

You can use millis() function for timing. See how to use millis()

jchia:
turn off after 30 minutes?

After 30 minutes since when?

If you mean simply since you powered up, and assuming you already have the blinking working using a delay()-less millis()-based approach then just put that existing code in an if() and compare millis() to 1800000 (being 30 minutes in milliseconds.) If the 30 minutes are up, don’t blink anymore.

If you mean 30 minutes from when you turned them on with a button or switch, you would capture that time from millis() into a variable (eg, turnedTheLedsOnAtMillis) and compare that to the ever-growing millis() until time’s up.

Hi, I have an Arduino Mega and am using a 9v battery instead of the 5V pin on the Mega. I tried using the 5V pin but because I need to power 20 diodes, there was not enough current. Now that I have a 9v battery connected, I cannot get the LEDs to blink. I need the LEDs to blink and self shut off within 30 minutes. However, I also need the 9V battery to connect it. Is there any way to do so? Thank you in advance!

Well, what I am looking to do is to code a timer so that after I press the On button, the device will turn on, but when left alone the LEDs will continue to blink for the following 30 minutes. In addition, I will be soldering this, so will (after soldered) the LEDs still blink and self turn off? Thank you!

If it's one of those square PP3 batteries, they are quite useless.

You're better of with 6 AA batteries.

Easy to do. Can you post your code?

jchia:
Well, what I am looking to do is to code a timer so that after I press the On button, the device will turn on, but when left alone the LEDs will continue to blink for the following 30 minutes. In addition, I will be soldering this, so will (after soldered) the LEDs still blink and self turn off? Thank you!

What "on" button? Do you have a wiring diagram or other project planning documentation?

Whether the LEDs still work after you solder them, depends on your wiring and soldering skills!

At schematic/circuit diagram would help because I can't even guess where everything is connected. Also you must have some code driving your 20 LEDs and posting that would also be useful.

Steve

What blink rate abd duration?

Do you want to switch that up as you progress then go rapidrapidly at the end?

All eady to do

This is all I have for my code. I don't need to speed or slow down the blink. However, I need the blink for all sets of LEDs to work together. I need 5 sets of 20 LEDs (which I have already) and I need them all to blink and shut off at the same time. In addition, because I had so many LEDs, I can only use a 9V battery, which means that my Arduino is not hooked up to the breadboard anymore. I will post a picture of my breadboard below.

Below is a picture of my code that I have right now (it is only to make the LEDs blink because I do not understand how to make the timer work) and a picture of my breadboard. Thank you!

Untitled document (5).pdf (72.2 KB)