0

Servo example error
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Servo example error

by WTS on Thu Feb 07, 2019 8:50 pm

I am going through the servo example found in
http://descargas.cetronic.es/ADAFRUITTRINKETM0.pdf

I downloaded and put the simpleio.mpy file into the CIRCUITPY/lib folder on the trinket M0.
Now I get this error:
Traceback (most recent call last):
File "code.py", line 6, in <module>
AttributeError: 'module' object has no attribute 'Servo'

Can anyone help?

-------------------------------------------------------- CODE --------------------------------------------------------------------
import time
import board
import simpleio

# For the M0 boards:
servo1 = simpleio.Servo(board.A2)
while True:
for angle in range(0, 180, 5): # 0-180 degrees, 5 degrees at a time
servo1.angle = angle
time.sleep(0.05)
for angle in range(180, 0, -5): # 180-0 degrees, 5 degrees at a time
servo1.angle = angle
time.sleep(0.05)
WTS
 
Posts: 6
Joined: Sat Jul 19, 2014 4:44 pm

Re: Servo example error

by oesterle on Thu Feb 07, 2019 9:04 pm

Hi, WTS!

According to a recent discussion here on the forums (Trinket M0 Servo Control Failure), simpleio.Servo has been replaced with adafruit_motor.Servo.

Your PDF is a snapshot from June 2018; I'd suggest using the online version which is more current: CircuitPython Servo | Adafruit Trinket M0 | Adafruit Learning System.

Cheers,

Eric

oesterle
 
Posts: 571
Joined: Tue Sep 17, 2013 11:32 pm

Please be positive and constructive with your questions and comments.