2
\$\begingroup\$

I'm trying to control a servo motor from a Trinket M0. My circuitpython code is:

import time
import board
import pulseio
from adafruit_motor import servo
pwm = pulseio.PWMOut(board.A4, duty_cycle=2 ** 15, frequency=1000)
my_servo = servo.Servo(pwm)
my_servo.angle = 180

But I get a ValueError saying that "PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)."

Full disclosure: this used to work but I accidentally short circuited my wiring by connecting the control wire of the servo to the reset pin of the Trinket M0. Is it possible that this would have damaged the SAMD21 on the M0?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution). .... that is the whole error message? .... there is nothing else? \$\endgroup\$ – jsotola Jun 18 '20 at 1:18
  • \$\begingroup\$ Nothing no. I ended up going for pwm = pulseio.PWMOut(board.A4, frequency=50) and that worked out fine for some reason. \$\endgroup\$ – garys Jun 18 '20 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.