pdf-icon

UiFlow チュートリアル

UiFlow1 開発ガイド

プロジェクト管理

LTEネットワークを使用する

UiFlow1 Blockly

Event

Unit

PWM

Example

Initialize the direction of the pin, and print the value of the pin on the screen.

from m5stack import *
from m5stack_ui import *
from uiflow import *
import machine
import time


screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)

i = None

label0 = M5Label('label0', x=137, y=88, color=0x000, font=FONT_MONT_14, parent=None)

PWM0 = machine.PWM(26, freq=50, duty=3, timer=0)
while True:
  for i in range(13):
    PWM0.duty(i)
    wait_ms(1000)
    label0.set_text(str(i))
  wait_ms(2)

API

machine.PWM(26, freq=10000, duty=50, timer=0)
  • Set the pin, frequency, duty cycle, and timer selection for generating PWM signals.
PWM0.freq(1)
  • Set the PWM frequency.
PWM0.duty(0)
  • Set the PWM duty cycle.
PWM0.pause()
  • Pause PWM signal generation.
PWM0.resume()
  • Resume PWM signal generation.
PWM0.hold_us(0)
  • Hold the PWM signal for a few microseconds.
On This Page