How to control LEDs

I am trying to control an custom external LED board with the pixhawk in auto mode. the challenge is that every LED color (R,G,B) has a signal wire connected an auxiliary pin on the pixhawk and in auto mode, the pixhawk can output a desired PWM to one channel using the DO_SET_SERVO command. I want to output different PWM values at a time to different channels for a single DO_SET_SERVO command

1 Like

Use scripting, it supports ProfiLEDs and NeoPixels.

1 Like

@iampete How do I use lua scripts when I am running in auto mode??

Lua scripts run independently in a separate thread when your FC boots up, to take control of what your lua script suppose to do after bootup you can time the events upon any conditions you like or can use RC switches to take control of events

@Notorious7 and @iampete. So haven’t fully explained what I am doing . I am controlling a swarm of light show drones and with the current capability of the pixhawk, only one servo channel can be controlled in an instance with DO_SET_SERVO command( that an control one LED color). What I want is to control 3 servo channels in an instance (to enable mixing of colors on the LED) else I will be stuck with only RGB for colors. The LED is made from custom PCB and is powered differently from the pixhawk. It only takes signal(PWM) from the pixhawk. Now with using LUA scripts, I would have to write a new script for individual drones which is not scalable

you can read the mission commands with scripting, or a file on the SD card

@iampete Can you please point me to examples like that? Because I am auto-generating the waypoint mission file from a python script and I am still seeing that the mission will be executing one waypoint to another, only one entry for a mission command is made available: reference from https://mavlink.io/en/file_formats/

Check these out for how to read and write files from SD card


And this for changing colors of RGB leds

@Notorious7 I am going to work on that

@Notorious7 one last ask, I am looking for line of lua script that will read the current mission index and print out all the parameters

https://github.com/ArduPilot/ardupilot/blob/ebfe593e38acefcc6d7d377f93e5d0cb9b9f81bc/libraries/AP_Scripting/examples/Mission_test.lua#L18 and https://github.com/ArduPilot/ardupilot/blob/ebfe593e38acefcc6d7d377f93e5d0cb9b9f81bc/libraries/AP_Scripting/examples/Mission_test.lua#L26