Custom LED Script

I have a $50 reward for anyone who can help me find a solution to my specific needs. i need a LED setup that runs 8 LED boards with 5 LEDs on each board (speedybee LED lights). can run all the boards LEDs, and is connected to the flight controller so that they can be switched at the press of a button. the setup is rather unique o it will require LUA scripting in order to right the light sequence. i need 3 light sequences that can be switched back and forth from mid flight via a button on the remote, those 3 being: Red and Blue flashing, Nav lights - standard red, green based off orientation, and a mode to turn off all leds completely.

this should be a rather straightforward and easy project, i just have tried and tried and simply don’t understand how to use the LEDs. as soon as you give me some credible Help, ill give you $25, and after it works, another $25.

what i need: 1, what hardware do i need to aciure? currently i have a Pixhawk 6X running the latest ardupilot, and 8 Lumenier Digital RGB Arm 6 LED Board (can be found on getfpv) but, in order to wire them up and run a LUA skript will i need more then just that? like a adafriut? and i will need a working LUA script i can use that will do the 3 light configurations above.

Those LED strips will work as they are, probably run them all from a 5v BEC so they dont affect the flight controllers own 5v supply. Each of their signal pins (and ground) will connect to servo outputs setup for “Neopixel” and work fine with the correct scripting.

These leds seem to be using ws2812b standard. you could connect the din of first to any output port on the fc (like AUX1, etc) and give it 5v externally. connect the dout of the first strip to the din of the next, and so on. set the protocol to WS2812B LED in Mission Planner and follow this wiki guide: NeoPixel — Copter documentation. this would basically daisy chain all the leds together, but you could still seperately address leds. The default setup will use them like this page suggests (the RGB section):LEDs Meaning — Copter documentation. if you want custom control, use these LUA scripts (refer to the wiki for setting up lua): ardupilot/libraries/AP_Scripting/examples at master · ArduPilot/ardupilot · GitHub. You could use some reference from the LED scripts here and then you could make a custom lua script.

Just for fun, I asked chatgpt. and here is a solution provided :slight_smile:

If this solution works then please donate the money to someone who needs it. Good luck.

Yes — this can be done without an Adafruit/Arduino, as long as those Lumenier/SpeedyBee boards are standard 5V WS2812 / NeoPixel-style digital RGB LEDs.

One important correction: the board you named is Lumenier Digital RGB Arm 6 LED Board, which is listed as 5V input and 60mA–160mA current draw depending on LED color. So 8 boards would be roughly 0.48A–1.28A, but I would still use a separate 5V 3A BEC to be safe.

Hardware you need

Item Needed? Notes
Pixhawk 6X Already have Good; ArduPilot Lua supported
8 digital RGB LED boards Already have Confirm they are WS2812/NeoPixel type
External 5V BEC, 3A minimum Yes Do not power all LEDs from Pixhawk servo rail unless current capacity is confirmed
330–470 ohm resistor on data line Recommended Put in series between Pixhawk AUX signal and first LED DIN
1000µF capacitor across 5V/GND Recommended Put near LED power input
Common ground wire Required Pixhawk GND, BEC GND, LED GND must be tied together
JST/servo wire/pigtails Yes For clean wiring
Logic level shifter 3.3V to 5V Optional but recommended Some WS2812 LEDs work from 3.3V signal, some are unreliable

ArduPilot supports serial LEDs like NeoPixel from an output using SERVOx_FUNCTION, and for Lua control the output should be assigned to scripting output functions 94–109. ArduPilot also warns that serial LEDs require a DMA-capable output and, on flight controllers with IOMCU, serial LEDs should use AUX outputs, not MAIN outputs.

Recommended wiring

Use one LED data chain:

Pixhawk AUX signal pin → 330Ω resistor → DIN of board 1
DOUT board 1 → DIN board #2 → DIN board #3 … through board #8

Power wiring:

5V BEC + → all LED 5V pads
5V BEC – → all LED GND pads
Pixhawk GND → LED/BEC GND

Do not feed LED 5V from the Pixhawk unless you are only testing one board. Use the external BEC.

ArduPilot parameter setup

Assume you connect the LED data wire to AUX1. On many Pixhawk-style boards, AUX1 may correspond to SERVO9, but verify in Mission Planner for Pixhawk 6X.

Set:

Parameter Value
SCR_ENABLE 1
SERVOx_FUNCTION for the AUX output 94
Lua script location SD card: APM/scripts/led_modes.lua

ArduPilot says Lua scripts are stored on the SD card in the APM/scripts folder and scripting is enabled with SCR_ENABLE = 1.

LED count setting

You said 8 boards with 5 LEDs each, so:

8 × 5 = 40 LEDs

But the Lumenier board name says 6 LED board, so if they are actually 6 LEDs each:

8 × 6 = 48 LEDs

In the script below, change:

local NUM_LEDS = 40

to:

local NUM_LEDS = 48

if each board really has 6 LEDs.

Lua script: button cycles 3 modes

This uses an RC channel as a momentary button. Example uses RC channel 7. Each press cycles:

  1. Red/Blue flashing

  2. Navigation lights

  3. All LEDs off

    – Assumption:
    – LEDs 0-19 are left side
    – LEDs 20-39 are right side
    – Adjust these ranges to match your physical wiring/order.
    local half = math.floor(NUM_LEDS / 2)

    You do not need an Adafruit board if the LEDs are WS2812/NeoPixel. You need a 5V BEC, common ground, and one Pixhawk AUX output configured as SERVOx_FUNCTION = 94. The Lua script can control the LED chain directly through ArduPilot using serialLED:set_num_neopixel() and serialLED:set_RGB(). ArduPilot’s own example scripts use the same serial LED functions.

    The only real question is physical LED order. For proper navigation lights, you need to wire the boards so the script knows which LEDs are left side, right side, and rear. If the order is different, the LED ranges in the script need to be adjusted.

led_modes.lua.txt (3.4 KB)

More simple problem: have different colours on WS2812 type leds, with no possible lua script, red on front left and green on front right, for orientation. Led strip single line on FC. I modified sources and compiled.