Best way to control LEDs on RC ship

My project is a 2 meter long RC boat that reads a receiver's signal using Arduino and converts the commands to different servos/controls. More details on my GitHub repo, but that's ancillary.

Ironically, the most difficult thing for me to understand is how to drive LEDs. My idea was to turn certain sets of lights on/off at a distance, like real ships would. The difficulty is that there are arbitrary numbers of LEDs, each of which could be on an arbitrary circuit set.

  1. The least complicated method would of course be to have a converter bring the current down to about 3V and plug all the LEDs. This would have no RC functionality.

  2. The next simplest solution would be creating sets of LEDs that can be turned on or off separately. Not the finest control, but still an interesting radio-operated effect.

  3. A finer solution would be to use a driver board. I tested an Adafruit PCA9685 16-Channel Servo Driver, but unfortunately each of the pins only supports 25mA. Also, each light has to be wired individually to the board, which in a large boat gets complicated as you can imagine. Finally, the Arduino is quickly running out of pins; it would be preferable to keep this project at 1 Arduino to keep complexity manageable.

I'm heading somewhere between solutions 1 and 2. But first, there are a few things to clarify about LEDs. Here's an example data sheet on 5050 SMDs:

In my understanding, these LEDs are actually 3-in-one. Question: are they referring to the whole LED chip with these data points (Warm White, 60mA and 2.8-3.4V)? Additionally, I'm not sure how to mix 3mm LEDs with SMDs (some areas where LEDs are visible, like the mast, will benefit from their shape, while others flat surfaces would make SMDs easier to install).

Also, question: how do I find a transistor, mosfet, or other that allows me to control the voltage to these LEDs with Arduino, having the correct specifications? I.e. control 3.4V LEDs with 5V Arduino logic. An additional consideration is that with this being mounted into a vehicle, it must be reliable and easy to install, meaning I can't spend a whole bunch of time calculating Ohms and soldering loose capacitors and so on. It needs to be fixed on PCBs that accept standoffs and can be screwed or glued. Circuits are my weak point, so any time a cheap alternative is available to save brain cells it's preferable.

Finally, any advice on how to research fuses and where/how to install them in this particular scenario? It's helpful to get general advice while prototyping everything together. This will be my first time putting so many components together. Last boat, had prototyped Arduino speed controllers, but these were finally omitted because of reliability concerns. This time I'm committed to doing everything right :wink:

In my understanding, these LEDs are actually 3-in-one. Question: are they referring to the whole LED chip with these data points (Warm White, 60mA and 2.8-3.4V)?

What do you mean by 3-in-one? If you mean RGB leds, I don't think they are. They are single colour, each identified by a different part number. The specs refer to each part/colour. EDIT: I get it now (sorry). They have 3 leds inside each package. I think the specs do refer to the package as a whole, 3x20mA=60mA sounds right. It's possible each led's anode and cathode have separate terminals, or they could be connected in parallel inside the package. The data sheet should show which. Please post a link to that.

how do I find a transistor, mosfet, or other that allows me to control the voltage to these LEDs with Arduino, having the correct specifications? I.e. control 3.4V LEDs with 5V Arduino logic.

You don't need to control the voltage with leds, you need to control the current. I know you find those 2 concepts confusing, but you need to get your head around the differences or you will roast a lot of leds.

I suggest you have a more detailed think about how you want to control these leds. Which need to be controlled individually and which as as groups? Which need to be dimmed, not just on/off? Make a list of each group/indiviual led, how many in each group, what colour etc and post that list for us to see.

For groups of leds, it is more efficient to use the 12V supply directly, allowing multiple leds to be connected in series where possible and in parallel otherwise. This wizard will show you the best ways to connect the leds in each group and what resistor values to use. Not all of its suggestions are good, so let us check them over for you first.

Given that you already have a switchmode down-regulator to provide 5 V for the Arduino (Nano - correct choice) and LEDs, the smartest way to control single colour LEDs without individual brightness control is with a MAX7219 per group of 64 wired in a matrix.

Easiest way to do this is to buy one or more of the matrix module kits from eBay or Aliexpress, ignore the matrix provided and use the PCB to connect your LED groups. No more than 16 wires are needed to connect up to 64 LEDs.

Different modes give the following light setups:
Steaming lights:

  • Anchor lights
  • 2x navigation lights (green + red 3mm)

Anchor:

  • 3x topmast steaming lights + stern light (white 3mm) *simplified from single forward mast so both lights can be on same switch
  • All deck lights

Deck lights:

  • 12x (white SMD)

Helicopter deck lights:

  • 12x (green SMD)

Bridge lights

  • 6x (white SMD)

Simplified scheme from a reference schematic:

Broken down in list format, that would give:

  • 2x red + green 3mm (navigation lights)
  • 3x white 3mm (anchor lights)
  • 12x warm white SMD (deck lights) + 6x warm white SMD (bridge lights)
  • 12x green SMD (helicopter deck)

These individual circuits only need to be turned on and off, no dimming, strobing, etc.

Assuming the following for all, with source voltage of 5V:

  • 3mm LEDs: forward voltage 3.3V, current 18mA
  • 5050 SMDs: forward voltage 3.3V, current 60mA

Navigation lights

each 100 ohm resistor dissipates 32.4 mW
the wizard thinks 1/4W resistors are needed for your application
together, all resistors dissipate 64.8 mW
together, the diodes dissipate 118.8 mW
total power dissipated by the array is 183.6 mW
the array draws current of 36 mA from the source.

Anchor lights

each 100 ohm resistor dissipates 32.4 mW
the wizard thinks 1/4W resistors are needed for your application
together, all resistors dissipate 97.2 mW
together, the diodes dissipate 178.2 mW
total power dissipated by the array is 275.4 mW
the array draws current of 54 mA from the source.

Deck and bridge


each 33 ohm resistor dissipates 118.8 mW
the wizard thinks 1/4W resistors are needed for your application
together, all resistors dissipate 2138.4 mW
together, the diodes dissipate 3564 mW
total power dissipated by the array is 5702.4 mW
the array draws current of 1080 mA from the source.

Helicopter deck

each 33 ohm resistor dissipates 118.8 mW
the wizard thinks 1/4W resistors are needed for your application
together, all resistors dissipate 1425.6 mW
together, the diodes dissipate 2376 mW
total power dissipated by the array is 3801.6 mW
the array draws current of 720 mA from the source.

Paul__B:
Easiest way to do this is to buy one or more of the matrix module kits from eBay or Aliexpress, ignore the matrix provided and use the PCB to connect your LED groups. No more than 16 wires are needed to connect up to 64 LEDs.

IDK much about matrix arrays, but taking a look at them last night, there would be rows of 8 LEDs connected together. My needs are a bit arbitrary compared to that. Would it be possible to connect fewer LEDs and change the resistance? Would it require using only one type of LED?
I'm also not sure about the pins required. The Arduino already has these connections taken (most item are on order, the only thing tested yet is servo and receiver pins):

  • 6x digital pins for receiver signal intercept
  • 2x PWM for motor speed
  • 2x for motor direction
  • 1x for amplifier tone (I believe)
  • 3x for servos (PWM output, one of them is the rudder, the other the radar, other theoretically for garage door, may install two more doors later)

Am I understanding correctly in saying there are three control pins? DIN, CS, CLK, requiring exact pins 11, 12, 13?

PaulRB:
They have 3 leds inside each package. I think the specs do refer to the package as a whole, 3x20mA=60mA sounds right. It's possible each led's anode and cathode have separate terminals, or they could be connected in parallel inside the package. The data sheet should show which. Please post a link to that.

Thank you. Haven't selected any hardware yet, but will know to take a look if necessary. According to what I've seen, there are three separate cathodes to solder on one side and three separate anodes on the other, which would put them in parallel.

OK, I now have the time to look a bit closer.

The 5050 LEDs with three chips each would be expecting 20 mA per chip, 60 mA total at around 3 V. To drive LEDs, you do not use a voltage source, you use a current limiting resistor or a driver chip. The MAX7219 is in fact, a driver chip; one resistor programs the current for all 64 LEDs, you do not need any more resistors and while theoretically you would need a different resistor for different colours, in practice a 10k resistor works just fine for any colour.

If you have - as is usually the case - a 5 V supply, then the resistor drops about 2 V assuming 3 V for the LED. So a 100 Ohm resistor will provide 20 mA (150 Ohm would however be more conservative) and if you wanted to parallel all three elements in the 5050 LED, then a 33 (or 47) Ohm resistor would indeed provide 60 mA. 60 mA at 2 V is 120 mW; a 1/8 Watt resistor would do and a common ¼ Watt resistor would be conservative.

If using the MAX7219 - which remains the best approach - then the three elements in the 5050 LED would necessarily be wired as separate LEDs and be able to be controlled individually by the MAX7219 to give three alternate brightness levels. :grinning:

In order to discuss this further, I suggest you clearly explain the total number of LEDs - including the numbers of single and triple LEDs - that you propose to use. If the number of LED elements exceeds 64, you would want more than one MAX7219 which is absolutely no problem at all; several MAX7219s are still controlled by only three arbitrary digital pins, you are not compelled to use the SPI pins.

As previously mentioned, the easiest way to use the MAX7219 is to get a partly assembled matrix module, do not mount the matrix or its socket pins but solder your own LED matrix to the board pads. Only 16 connections for 64 LEDs.

Aliexpress item

Paul__B:
In order to discuss this further, I suggest you clearly explain the total number of LEDs - including the numbers of single and triple LEDs - that you propose to use. If the number of LED elements exceeds 64, you would want more than one MAX7219 which is absolutely no problem at all; several MAX7219s are still controlled by only three arbitrary digital pins, you are not compelled to use the SPI pins.

Thank you for your answer. What I’m struggling to understand is what happens if the number of LEDs used is not exactly 64?

A MAX7219 can control 64 LEDs in an 8 by 8 matrix - eight cathode commons and 8 anode commons.

It really does not care whether a LED exists at any of the 64 intersections; if programmed to light a LED at a particular point, it will provide the appropriate current drive but if there is no LED, then of course no current will flow. It is no different to setting an Arduino output HIGH but having nothing connected.

If you have more than 64 LEDs, you use two MAX7219s. The MAX7219 multiplexes by driving one "column" (cathode group) of 8 at a time and while you can have 8 columns, you can program for fewer and it will only switch through the number of columns specified, so you can for example drive only four columns for up to 32 LEDs.

If you have more than 64 LEDs (and less than 113) to drive, you nave two MAX7219s and should distribute the LEDs in smaller matrices evenly over the two MAX7219 drivers so that they obtain the same multiplex duty cycle on both.

I feel like you are ignoring my advice. If that's the case, please let me know and I will un-follow this topic and stop bothering you.

Is there a reason you need to use 5V supply rather than 12V?

When I asked you to group the leds and make a list, I didn't mean make random groups. I meant groups that go on/off together. For example:

Different modes give the following light setups:
Steaming lights:
Anchor lights
2x navigation lights (green + red 3mm)

This isn't a group. Nav lights would not be on together with anchor lights. An anchor light is not a steaming light. Anchor lights would only be on when the vessel is at anchor. Nav and steaming lights only on when the vessel is under way. So please organise your leds into a better list.

I would recomend running all your leds directly from the 12V. This reduces the current required, saving battery life, removing the need for a high current 12V-5V buck converter and reducing the number of current limiting resistors needed. To save arduino pins and keep the circuit and wiring simple, I would use 1 or more tpic6b595 to drive the led groups.

According to what I've seen, there are three separate cathodes to solder on one side and three separate anodes on the other, which would put them in parallel.

No, if that's true, you have the option to use them in serial or parallel.

PaulRB:
Is there a reason you need to use 5V supply rather than 12V?

Not particularly. My impression was that LEDs need lower voltage and current, but I guess it does make sense to use the battery directly (with the understanding that battery voltage varies from 14V at full charge to 10V).

[…] please let me know and I will un-follow this topic and stop bothering you.

Actually, I think it’s amazing to have advice from others, as my knowledge of circuits is weak. It does take me some time to research before replying; sorry about that.

When I asked you to group the leds and make a list, I didn’t mean make random groups. I meant groups that go on/off together.

To clarify:
Groups:
Anchor lights → 3x white 3mm
Navigation lights → 2x red and green 3mm
Deck and bridge lights → 18x white SMD (for simplicity, we assume the deck and bridge lights always go on together)
Helicopter deck → 12x green SMD (I now learned on better information that this is actually, amber, red, and green, the amber lights turning red when the helicopter must no longer move; but I’m abstracting that detail away for now)

  • Anchor lights always go on with deck and bridge lights (technically, these as a whole could be called anchor lights, but both groups are used separately)
  • Nav lights always go on with anchor lights; together they make the “steaming lights” (to clarify, in the real world the anchor lights are two, and the steaming lights are three, but for a model this is close enough)
  • Deck and bridge lights can be turned on separately at any moment, except when they are required to be on at anchor
  • The helicopter deck is also separate and can be turned on independently
    These are the smallest independent groups: they do not all go on or off monolithically. The plan is to let the user decide through the radio. For example, stopping the motors for five seconds turns on anchor lights, and the right throttle controls the heli deck, etc. Coding is not an issue if the groups are independent.

Let’s do this again for 12V. This is again assuming the following:

  • 3mm LEDs: forward voltage 3.3V, current 18mA
  • 5050 SMDs: forward voltage 3.3V, current 60mA

Nav lights (red + green sidelights)

Anchor lights

Deck lights and bridge


Helicopter deck

> No, if that’s true, you have the option to use them in serial or parallel.
The only reason I’m suggesting SMDs is that they are a good form factor to place flat on the surfaces of the model, and have the same shape as the actual lights would for the helicopter deck. There is no need to use the three separate lights inside the chips, nor do I have any experience using those LEDs in particular.

After watching Drone Bot Workshop's video on shift registers, I think I understand how the number of pins gets multiplied, but am not sure how 12V input would be used to control the register, or how that would wire if that's expressed properly.

Is there a resource to read that would explain how that is done?

Paul__B:
It really does not care whether a LED exists at any of the 64 intersections; if programmed to light a LED at a particular point, it will provide the appropriate current drive but if there is no LED, then of course no current will flow. It is no different to setting an Arduino output HIGH but having nothing connected.

I get what you're explaining here; I could connect row 1 to 8 LEDs and row 2 to 4 LEDs, and turning on both rows in code would give 12 LEDs == heli deck. (It's also nice there's room for flexibility with the number of lights). In this case, there would be two positive and two negative wires going to the heli deck, using two sets of pins on the matrix.

If using the MAX7219 - which remains the best approach - then the three elements in the 5050 LED would necessarily be wired as separate LEDs [...]

So this would complicate things quite a bit. From my understanding, the MAX7219 is only providing 20mA, so each 5050 SMD requires three connections at this point. So our helicopter deck is no longer taking up 12 LED spots, it's taking 36 on five rows, with 10 wires going from the electronics area back to the helicopter deck. Ouch. I suppose the best choice then would be to forget SMD business and buy square LEDs. That way the look would be the same without need for complification.

If you have - as is usually the case - a 5 V supply, then the resistor drops about 2 V assuming 3 V for the LED. So a 100 Ohm resistor will provide 20 mA (150 Ohm would however be more conservative) and if you wanted to parallel all three elements in the 5050 LED, then a 33 (or 47) Ohm resistor would indeed provide 60 mA. 60 mA at 2 V is 120 mW; a 1/8 Watt resistor would do and a common ¼ Watt resistor would be conservative.

Well, I have a 12V supply and a 5V step-down. As @PaulRB pointed out, my 5V supply may get overdrawn, which may require an additional step-down converter, but that's tangential. (On a side note, would there happen to be a dot matrix directly capable of 12V without using a converter?)
My reason for posting on this forum is determining what's the best way of switching groups of LEDs on/off. I'm not sure what the proposal is here. Probably just confused.

Thank you both for your answers. Pending time change, let me know what you think: will shift registers be easiest to install, or a matrix? I'm gathering that a matrix is more self-contained, being already on a board -- assuming the use of 20mA LEDs. On the other hand, it seems that shift registers would be more flexible with voltage and amperage, but would require fixing them to a board somehow and installing every resistor myself. Is that correct?

I think Paul__B's suggestion of using max7219 was based on the initial impression that you might want to control evey led indivudually, in which case it would have been an ideal solution. But now we know that you only need control of groups of leds, I think it makes more sense to wire the groups to the 12V supply and use the tpic chips to control them.

Each tpic chip has 8 individually controlled channels and multiple chips can be cascaded/chained together so that only 3 arduino pins are needed to control almost any number of channels. Unlike the normal 74hc595 shift registers, the tpic6b595 chips can switch up to 18V I think and up to 150mA per channel.

If your battery could be as high as 14V (li-ion packs, rather than sla?) then you should use 14V when using the wizard or calculating the current limiting resistors, for safety. When the actual voltage is around 12V or 10V, the leds will be a little less bright, but not noticeably so.

TPIC6B595 is rated to 50V.

Great, thanks @Crossroads, no problem at all with 14V then.

If 150mA is not enough, there is also tpic6a595 which is 250mA per channel. You can mix any combination of 74hc595, tpic6c595 and tpic6a595 you like, still only 3 arduino pins needed.

I agree. If you merely want to control LEDs in groups, then a TPIC6B595 will control (up to) eight groups at 150 mA each, each of the eight outputs connected to the current limiting resistors of that group and the anode end of the group connected directly to your 12 V SLA battery. The logic circuit of the driver chip itself is powered by the same 5 V supply as the Nano.

For 12 to 14 Volts, you put three LEDs in series for each path and calculate the series resistor on 14 V which is the charging voltage of the battery. There is no need to maximise the LED current; the difference between 15 mA and 20 mA will be barely distinguishable. For the SMD 5050 triple LEDs, you put the three elements in series with two "zig-zag" connections underneath and run the series chain with the resistor from 14 V at 20 mA.

So with all 20 mA chains, each TPIC6B595 can drive seven chains. That would be up to 56 chains of 3, 20 mA LEDs. I don't think you need that many, so you can distribute larger groups evenly over more than one TPIC output.

Thank you for the follow-up. Happened to have a 74HC595 hanging around to get a feel for it. I'll put the shift register and LEDs on order.

I assume the best way to assemble this is on prototype board (don't own any)?

Yes, soldered together would be best.
I use Velleman ECS1/2, high quality perf board, doesn't warp, holes are all aligned very nicely with plenty of pad to solder to.
Hunt around, you can get them in the $4 range, example: