Micropython PWM example for Giga R1

Just got a Giga R1 and I've set it up to run micropython. I'm having trouble finding a micropython pwm example to control a motor. The examples using pwm from the micropython machine library don't seem to work and the pwm function from the Timer library gives me an error:

"Pin (A3) doesn't have an alt for Timer(1)"

I'm hoping I can have a look at code that works to learn haw to properly set up the Timer function. Here's the micropython code I used:

from machine import Pin
from pyb import Timer

motorPin = pyb.Pin.board.PA3
timer = pyb.Timer(1, freq = 1000)
ch2 = timer.channel(2, mode = pyb.Timer.PWM, pin = motorPin, pulse_width_percent = 50)

Thanks

I have similar problem when I run,

from machine import Pin, PWM, ADC

"Cannot import name PWM"

Have you got your answer? Do you like to share? Thanks

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.