How to get altitude via mavlink?

Yours is harder to read :wink:

Better? :slight_smile:

function update()
pwm9 = rc:get_pwm(9)
pwm10 = rc:get_pwm(10)
pwm12 = rc:get_pwm(12)
pwm13 = rc:get_pwm(13)
if pwm9 > 1700 then vehicle:set_mode(3)
elseif pwm10 > 1700 then vehicle:set_mode(5)
elseif pwm12 > 1700 then vehicle:set_mode(6)
elseif pwm13 > 1700 then vehicle:set_mode(2)

end
return update, 100
end
return update, 500

No. There is no indication what any of your “magic numbers” mean and does not adhere to any coding practice whatsoever.

Even mine could be cleaned up (it should include a function rather than repetitive code), but I didn’t want to go too far down “best practice” rabbit holes.

okok but it works good and is light, at the moment will stay.