Hw output pwm duty cycle

From Sim Innovations Wiki
Jump to navigation Jump to search

Description

hw_output_pwm_duty_cycle(hw_output_pwm_id, duty_cycle)

hw_output_pwm_duty_cycle is used to change the duty cycle of a PWM output.

Return value

This function won't return a value.

Arguments

# Argument Type Description
1 hw_output_pwm_id String The is the reference to the PWM output. You can get this reference from the hw_output_pwm_add function.
2 duty_cycle Number The new PWM duty cycle. Range 0.0 - 1.0, 0.0 being off, and 1.0 on.

Example

-- Bind to Raspberry Pi 2, Header P1, Pin 40
-- PWM frequency is set to 1 kHz, with a duty cycle of 50%.
output_id = hw_output_pwm_add("RPI_V2_P1_03", 1000, 0.5)

-- We can change the duty cycle runtime, in this case 20%
hw_output_pwm_duty_cycle(output_id, 0.2)