Skip to content

Commit

Permalink
AP_Scripting: examples: update servo scan
Browse files Browse the repository at this point in the history
  • Loading branch information
IamPete1 committed Apr 2, 2024
1 parent b904ab2 commit c96c89a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions libraries/AP_Scripting/examples/servo_scan.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
-- move a servo in a sinisoidal fashion
-- move a servo in a sinusoidal fashion

local SERVO_FUNCTION = 94
local PERIOD = 0.5
local FREQUENCY = 0.125

function update() -- this is the loop which periodically runs
local t = 0.001 * millis():tofloat()
local pi = 3.1415
local output = math.sin(pi * t * PERIOD * 2.0)
local output = math.sin(math.pi * t * FREQUENCY * 2.0)
local pwm = math.floor(1500 + 500 * output)
SRV_Channels:set_output_pwm(SERVO_FUNCTION, pwm)
return update, 20 -- reschedules the loop at 50Hz
Expand Down

0 comments on commit c96c89a

Please sign in to comment.