Controlling 5v LED strip using arduino nano

Hi there, I am new in using an arduino nano and for my project which is an electric longboard controlled by an app, I am adding a light switch on the app, which should simply turn on and off the two strips of LED lights.

On those LED lights there are only two pins which are 5v and GND (check image), thus my question is :

How do I connect the two LED strips to my arduino and where should I draw the power from?
Do I need to use a logic-level mosfet?

I am also using a VESC, thus can I draw the power from one of the 5v pins?

I have seen so many threads and tutorial talking about the 12v addressable or non-addressable lights, or the neopixels ones or the WS2813. However, i have not seen any which are simply talking bout LED lights with 2 pins, a 5v one and a GND one

If you start with the basic spec of 320 LEDs per metre shown in the photo, you can start with a safe guess of around 6 Amps per metre needed.

Your ‘dirty +5’ supply to the (+) terminal
You may like to inject power at more than one position on the LED strip.

A logic-level N-channel MOSFET Drain pin between the (-), and Source pin to your 0V supply.

A 2K2 resistor from any PWM pin to the MOSFET gate pin….

Twiddle the gate with PWM to adjust the brightness.

And away you go.

sorry, i did not specify but it is only 0.5 meter so there are only 160 LEDs

there is no brightness to adjust, it's simply an either on or off situation.

Thank you for your fast reply!!

Also, sorry if it is too much to ask, would you be able to make a diagram of the connection, so that I do not connect anything wrongly ?

This is the wiring diagram on page 5 called usage.

Although you only need one FET because your strip only has one colour of LEDs not three.

PWM is something in the Arduino code you adjust.

thank you for the diagram!!

alright thank you, and I assume that I can connect both strips with one FET right ?

also, i was wondering if i could use a 2k resistor as I have some available already, or is it better to have a 2k2?

I would use something in the 50 Ohm range from the PWM to the MOSFET gate and something in the 10K range from the PWM pin to ground. Be sure all the grounds are connected. This 10K will keep the LEDs off during power reset until your code takes control. With it floating it can go to an indeterminate state and possibly fry the MOSFET if it gets to hot. 3A (0.5 meter) can produce a lot of heat.

Yes wire them in parallel but make sure the FET can handle the current.

Yes it makes no practical difference, it is just that 2K2 is much more of a common value than 2K.

so if I understood all your answers correctly this is the connection:

any PWM pin connected to 2k resistor connected to Gate pin on MOSFET

Source connected to Drain pin connected to GND on strip

5v pin on arduino connected to +ve wire on strips ?

But

You need to consider the gate capacitance, it forms an rc with the input resistor. This causes it to switch slower. While the MOSFET is in this intermediate range it dissipates a lot more heat. Remember it is like a resistor going from a high resistance to a low resistance. The more current switched the more this will affect its operation. You can skip the resistor if you want, the current pulse during turn on and off should be tolerated by the Arduino. If you were PWMing it would be worse.

hi, i understand what you are saying, however, i am not quite understanding or have any clue of how to properly connect the whole circuit.

they did send me a diagram of it but i am still not too sure of the exact wiring connection.

Also which mosfet do you recommend ? As i have never used one before

Like this

The IRLB8721

1 Like

That should work just fine for the mosfet but you will fry your arduino. Rule #1 The Arduino A Power Supply IT IS NOT! You need three amps for each LED strip. You also need power for the Arduino. Your frizzy picture is missing power sources. It shows an UNO, not a Nano. So far you tell us it is for a longboard but how do you power it?

alright thank you, i just wanted confirmation, as i didnt want to do something wrong and end up frying my arduino

yh i thought bout that, and was thinking of powering it from the VESC which is also powering the arduino.

the main source of power is a a 10s lipo battery

That is a 36 Volt battery. The Arduino cannot take that voltage, anything much more than 12V will fry it. Your best solution is to use a small buck converter and power the Arduino via Vin, with about 8V, that will give you some extra filtering. The LEDs you can do the same thing but you want to multiply your LED current by about 125% then your buck converter for the LEDs should be able to supply that amount or more in amps. This will keep everything cool.

Sorry my bad, the arduino is powered by the VESC through a 5v pin.
It is the VESC that is powered by the 10s battery

1 Like

Do not power the LEDs with that 5V unless you can validate it can support the current. Good Luck.

Which is pretty much nonsense, as "filtering" the supply for a digital device makes no sense.

If you have more than a 5 V supply, you use a switchmode "buck" converter set to 5 V - because that is the voltage on which the Arduino actually runs, and feed it into the "5V" pin.

But you should disconnect the 5 V supply from a UNO while plugging it into a PC. Not a problem with the Nano.

Try this link, it will help you to understand where I was coming from. The regulator is an expensive filter but it is already there, why not use it? 3 Ways to Reduce Power-Supply Noise | Electronic Design

Sorry, but it doesn't help at all! It is entirely irrelevant to the situation of operating a digital microcontroller! The Arduino does not care about some noise on its power rails within reason because it is a digital logic device.

As long as inputs are outside the specified thresholds for HIGH and LOW, it will continue to operate perfectly. It would take some substantial variation of the supply voltage to affect these thresholds, way more than the few millivolts that a switchmode regulator might produce.

There is of course an exception. Analog readings. This is why the ATmega is designed with a separate supply rail for the analog section, to which you can apply a filter - either RC or LC as detailed in the article you link - to this supply point.

So

Because it wastes power.

Because there is a risk that someone knowing no better, may attempt to use it to supply a load other than the microcontroller. As of course you observed in #17.

The fact is that the use of linear regulators to power digital devices has "had its day". Virtually no recent designs use them, they just don't; rather switchmode supplies.