Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can devicescript use PWM? #705

Open
ken1691 opened this issue Oct 17, 2024 · 0 comments
Open

Can devicescript use PWM? #705

ken1691 opened this issue Oct 17, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ken1691
Copy link

ken1691 commented Oct 17, 2024

Can devicescript use PWM?
For example, micropython does this:

from machine import Pin, PWM
import time

# 配置PWM引脚
ir_pin = Pin(14, Pin.OUT)
pwm = PWM(ir_pin, freq=36000)  # 设置载波频率为36KHz

# 发送一个简单的红外信号
def send_ir_signal():
    pwm.duty(512)  # 设置占空比,50%占空比
    time.sleep_ms(100)  # 发送100ms的信号
    pwm.duty(0)  # 关闭信号
    time.sleep_ms(100)  # 间隔100ms

# 主循环
while True:
    send_ir_signal()
    time.sleep(1)  # 每秒发送一次
@ken1691 ken1691 added the enhancement New feature or request label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant