I have connected a relay switch module to pixhawk (rover firmware 4.0.0) and I can change it with dedicated buttons of the Joystick, but I would like to switch it with the same buttons I use to arm and disarm the system but I can’t get it…
Now I have another issue. I need to read a external button connected to AUX_OUTPUT 5. I tried to use the Lua script:
-- This script is an example button functionality
gcs:send_text(0, "Button check")
local button_status = 0
function update() -- this is the loop which periodically runs
gcs:send_text(0, "Button check 1")
button_status = button:get_button_state(1)
if (button_status == 1) then
gcs:send_text(0, "Button on")
else
gcs:send_text(0, "Button off")
end
return update, 1000 -- reschedules the loop (1hz)
end
return update() -- run immediately before starting to reschedule
I have BTN_ENABLED = 1 and BTN_PIN1 = 54
I have connected the button betwen the ground pin and the signal pin of the Pixhawk but it doesn’t work.
-- This script is an example button functionality
local button_number = 1 -- the button numbber we want to read, as deffined in AP_Button
local button_active_state = true -- the 'pressed' state of the button
local last_button_state
function update() -- this is the loop which periodically runs
local button_new_state = button:get_button_state(button_number) == button_active_state
-- the button has changes since the last loop
if button_new_state ~= last_button_state then
last_button_state = button_new_state
if button_new_state then
gcs:send_text(0, "LUA: Button pressed")
else
gcs:send_text(0, "LUA: Button released")
end
Why cant you use dev? Lost of other scripting improvements also. As ever in with dev firmware you should be more cautious setting everything up, but its not like a rover is going to fall out of the sky.