PWM
— 脉冲宽度调制是一种模拟控制方式¶
使用示例::(python)¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # coding=utf-8
# This is a sample Python script.
from driver import PWM
print("-------------------pwm test--------------------")
pwm = PWM()
pwm.open("pwm3")
duty = pwm.getDuty()
freq = pwm.getFreq()
print(duty)
print(freq)
pwm.setConfig(3250000, 0.5)
duty = pwm.getDuty()
freq = pwm.getFreq()
print(duty)
print(freq)
pwm.close()
print("-------------------pwm end--------------------")
|
配置信息::(json)¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # coding=utf-8
# This is a sample cjson file.
{
"io": {
"pwm0": {
"type": "PWM",
"port": 0
},
"pwm1": {
"type": "PWM",
"port": 1
},
"pwm2": {
"type": "PWM",
"port": 2
},
"pwm3": {
"type": "PWM",
"port": 3
}
},
"debugLevel": "DEBUG"
}
|