Hint on how to script pwm out controlled by micro switch

I would like to implement a function so that when an rc input is changed (switch from rc controller) an rc pwm out goes to a predefined value until a micro switch is triggered. This is to drive a esc driven motor to a mechanical stop.

How would I most easily setup something like this? Is a Lua script the solution or are there any simpler way? Seems like it should not be particularly complicated to achieve. I’m thinking the microswitch connects to a gpio pin.

Hardware is a pixhawk 1 clone “HKPilot32” (fmu v2) running copter 4.2.

Please point me in the right direction. Have never done any lua before, but do not even know if lua is the solution

Entirely possible in Lua. Look at the RC, button, and servo examples here:

Thanks! I will have a look at those examples

So is lua the preferred way of doing something like this. Or are there other options? ( like pythonscripting?)

Short of changing the source code, it is probably the only way to do what you’re asking.

Yuri I owe you a cold one! I’m an illiterate fool in coding, but with the examples you gave me I managed to piece together the script I needed. Thank you!!!

Is there any way to debug the script other than on the pixhawk ? I got a bit tired of removing the sd card everytime I tested new code