Servo moves with LUA

Hi! Maybe somebody can help me understand and fix my problem: the idea is to create a script that will do one move forward with servo after every click to rc10 button. Here is my script and it absolutely not work like that: local SERVO_FUNCTION = 94
local MOVE_AMOUNT = 100
local POSITION = 1500 – Середнє положення
local is_moving = false

function update()
local RC10 = rc:get_pwm(10)
if RC10 > 1500 then
is_moving = true
else
is_moving = false
end

if is_moving then
POSITION = POSITION + MOVE_AMOUNT
SRV_Channels:set_output_pwm(SERVO_FUNCTION, POSITION)
end

return update, 20 – reschedules the loop at 50Hz
end

return update()

I am not sure if your servo would move, but very clearly once you press the switch even for short period, the POSITION would increase at a rate of 50 uS per second. Not sure if that is what you meant by “move forward with servo after every click”. If you want the POSITION to change by one on switch press, then you should compare actual and previous switch value.