All of the general discussion from the previous sections still apply. Here we simply provide CircuitPython versions of the Arduino examples.

For the basics on using servos with CircuitPython, checkout the information in the Essentials guide:

The following examples show usage with a Feather RP2040 and the code is written for the pins shown. Use with a different CircuitPython board should be possible, but may require updating the code for the specific pins used.

Wiring

The example codes are based on the wiring shown below for connecting the servo:

  • SERVO POWER wire to USB
  • SERVO GROUND wire to GND
  • SERVO SIGNAL wire to A1
  • SERVO FEEDBACK (WHITE) wire to A3

Reading the feedback

The basic mechanism is the same as before - simply connect the feedback to an analog input and read the value. To learn more about reading analog inputs, see the Essentials guide:

All that is needed is to setup an analog input and get its value. Here's a simple code snippet that does that:

FEEDBACK_PIN = board.A3
feedback = AnalogIn(FEEDBACK_PIN)
position = feedback.value

The examples that follow will show this in more detail.

This guide was first published on Aug 24, 2013. It was last updated on Mar 05, 2023.

This page (Using With CircuitPython) was last updated on Mar 02, 2023.

Text editor powered by tinymce.