# Qwiic, Servos, and CircuitPython

**URL:** <https://community.sparkfun.com/t/qwiic-servos-and-circuitpython/42526>\
**Category:** Qwiic System\
**Tags:** qwiic\
**Created:** [August 2, 2021, 1:36pm UTC](https://community.sparkfun.com/t/qwiic-servos-and-circuitpython/42526 "2021-08-02T13:36:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gallaugher](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@gallaugher](https://community.sparkfun.com/u/gallaugher)\
**Post date:** [August 2, 2021, 1:36pm UTC](https://community.sparkfun.com/t/qwiic-servos-and-circuitpython/42526/1 "2021-08-02T13:36:09Z")

</div>

Hi! I purchased a Zio 16 Servo Controller for Qwiic from SparkFun, but it’s not entirely clear how to get this to work with CircuitPython over Qwiic. The board’s docs mention it’s based on the Adafruit PWM Servo Library and operates like their Feather Bonnets, but with Qwiic.

I’ve added a Qwiic Cable to an Arduino Nano RP2040 Connect & other Qwiic / STEMMA QT products work great. But I’m not sure how to get things working with a Zio. I’ve connected a Tower SG92R to Channel 0 on the Zio & have tried running sample CircuitPython servo code:

“”“CircuitPython Essentials Servo standard servo example”“”

import time

import board

import pwmio

from adafruit\_motor import servo

# create a PWMOut object on Pin A2.

pwm = pwmio.PWMOut(board.A2, duty\_cycle=2 \*\* 15, frequency=50)

# Create a servo object, my\_servo.

my\_servo = servo.Servo(pwm)

while True:

for angle in range(0, 180, 5): # 0 - 180 degrees, 5 degrees at a time.

my\_servo.angle = angle

time.sleep(0.05)

for angle in range(180, 0, -5): # 180 - 0 degrees, 5 degrees at a time.

my\_servo.angle = angle

time.sleep(0.05)

Since the Nano RP2040 has I2C on pins A4 and A5, I tried subbing out A4 first, then A5 in the code above. Code runs, but nothing happens. Any ideas on how to get this to work with CircuitPython? Thanks!

---

<div class="post-metadata">

**Author:** ![TS-Russell](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/ts-russell/32/6092_2.png) [@TS-Russell](https://community.sparkfun.com/u/TS-Russell)\
**Post date:** [August 2, 2021, 9:38pm UTC](https://community.sparkfun.com/t/qwiic-servos-and-circuitpython/42526/2 "2021-08-02T21:38:36Z")

</div>

_I could be totally wrong here_ I think you just need to tell it which channel to use; try adding [0] in the “while True” section…

my\_servo[0].angle = angle

Try that and see how it goes - it also might help if you can take a photo of your current wiring setup 😃

---

<div class="post-metadata">

**Author:** ![gallaugher](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@gallaugher](https://community.sparkfun.com/u/gallaugher)\
**Post date:** [August 3, 2021, 1:44am UTC](https://community.sparkfun.com/t/qwiic-servos-and-circuitpython/42526/3 "2021-08-03T01:44:10Z")

</div>

I tried a new board.

I no longer get the error I got previously.

Now trying this modified Adafruit code:

import time

from adafruit\_servokit import ServoKit

# Set channels to the number of servo channels on your kit.

# 8 for FeatherWing, 16 for Shield/HAT/Bonnet.

kit = ServoKit(channels=16)

print(“I’m totally runnin’, bro!”)

while True:

kit.servo[0].angle = 170

time.sleep(1.0)

kit.servo[0].angle = 5

time.sleep(1.0)

Nothing happens - no motor movement. Have tried using the servo via breadboard & servo works. Have also tried another servo on kit.servo[4], still nothing. Here’s a photo:

![]()

 ![For Sparkfun.png](https://canada1.discourse-cdn.com/sparkfun/original/3X/7/1/712590c2c8984871e4e959e67d75aff07f4430fd.png)

---

<div class="post-metadata">

**Author:** ![TS-Chris](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/ts-chris/32/6057_2.png) [@TS-Chris](https://community.sparkfun.com/u/TS-Chris)\
**Post date:** [August 3, 2021, 3:23pm UTC](https://community.sparkfun.com/t/qwiic-servos-and-circuitpython/42526/4 "2021-08-03T15:23:29Z")

</div>

Have you tried this library?

[https://github.com/ZIOCC/Qwiic\_Servo\_Driver\_PCA9685](https://github.com/ZIOCC/Qwiic_Servo_Driver_PCA9685)
