pca9685 - pca9685 16 Road PWM drive steering gear#
Adaptation status unknown
Note
This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!
Example
--Note: due to the use of sys.wait() all apis need to be used in the coroutine
-- Usage Examples
PROJECT = "pca9685"
VERSION = "1.0.0"
sys = require("sys")
pca9685=require("pca9685")
local i2c_id = 1
sys.taskInit(
function()
i2c.setup(i2c_id,i2c.SLOW)
sys.wait(1000)
pca9685.init(i2c_id,60)
sys.wait(1000)
local i=0
while true do
pca9685.setpwm(i2c_id,0,i)
if i >= 100 then
i=0
end
i=i+10
sys.wait(2000)
end
end
)
sys.run()
pca9685.init(i2cId,hz)#
pca9685 Initialization
Parameters
Incoming Value Type |
Explanation |
---|---|
int |
i2cid i2c id used, or an instance of software i2c |
int |
hz pca9685 The output frequency |
Return Value
return value type |
explanation |
---|---|
Return true on success |
Return true on failure nil |
Examples
None
pca9685.setfreq(i2cId,freq)#
pca9685 Set frequency
Parameters
Incoming Value Type |
Explanation |
---|---|
int |
i2cid i2c id used, or an instance of software i2c |
int |
freq pca9685 The output frequency of the range is 24HZ~1526HZ |
Return Value
return value type |
explanation |
---|---|
Return true on success |
Return true on failure nil |
Examples
None
pca9685.setpwm(i2cId,num, duty_cycle)#
pca9685 Set PWM Duty Cycle
Parameters
Incoming Value Type |
Explanation |
---|---|
int |
i2cid i2c id used, or an instance of software i2c |
int |
num Channel number |
int |
duty_cycle Duty cycle 0~100 |
Return Value
return value type |
explanation |
---|---|
Return true on success |
Return true on failure nil |
Examples
None