# Darth Faders

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/115/690/medium800thumb/3d_printing_darth.jpg?1664927418)

The machine is alive! Build this sci-fi prop/desk sculpture with motorized slide potentiometers, Feather RP2040, Motor FeatherWing, and CircuitPython.&nbsp;

Use the rotary encoder breakout to start and stop the motion, and to dial in specific fader poses.

https://youtu.be/PRO9oYsu4BI

## Parts
![](https://cdn-learn.adafruit.com/assets/assets/000/115/391/medium800/3d_printing_5466-01.jpg?1664296499)

### Part: Motorized Slide Potentiometer
quantity: 3
10KΩ Linear with 5V DC Motor
[Motorized Slide Potentiometer](https://www.adafruit.com/product/5466)

### DC Motor + Stepper FeatherWing Add-on For All Feather Boards

[DC Motor + Stepper FeatherWing Add-on For All Feather Boards](https://www.adafruit.com/product/2927)
A Feather board without ambition is a Feather board without FeatherWings! This is the&nbsp; **DC Motor + Stepper&nbsp;FeatherWing** which will let you use 2 x bi-polar stepper motors or 4 x brushed DC motors (or 1 stepper and 2 DC motors). Using our <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/2927)
[Related Guides to the Product](https://learn.adafruit.com/products/2927/guides)
![Video of 2 steppers spinning with rectangular black board on them powered by a DC Motor + Stepper FeatherWing Add-on For All Feather Boards](https://cdn-shop.adafruit.com/product-videos/640x480/2927-06.jpg)

### Adafruit Feather RP2040

[Adafruit Feather RP2040](https://www.adafruit.com/product/4884)
A new chip means a new Feather, and the Raspberry Pi RP2040 is no exception. When we saw this chip we thought "this chip is going to be awesome when we give it the Feather Treatment" and so we did! This Feather features the&nbsp; **RP2040** , and all niceties you know and...

In Stock
[Buy Now](https://www.adafruit.com/product/4884)
[Related Guides to the Product](https://learn.adafruit.com/products/4884/guides)
![Angled shot of black rectangular microcontroller "Feather RP2040"](https://cdn-shop.adafruit.com/640x480/4884-04.jpg)

### Assembled Terminal Block Breakout FeatherWing for all Feathers

[Assembled Terminal Block Breakout FeatherWing for all Feathers](https://www.adafruit.com/product/2926)
The&nbsp;Terminal Block Breakout FeatherWing kit is like the Golden Eagle of prototyping FeatherWings (eg. majestic, powerful, good-looking). To start, you get a nice prototyping area underneath your Feather, with extra pads for ground, 3.3V and SDA/SCL. Not one to stop there, we expanded the...

In Stock
[Buy Now](https://www.adafruit.com/product/2926)
[Related Guides to the Product](https://learn.adafruit.com/products/2926/guides)
![Angled shot of rectangular terminal block breakout board with green terminal blocks.](https://cdn-shop.adafruit.com/640x480/2926-09.jpg)

### Adafruit I2C Stemma QT Rotary Encoder Breakout with NeoPixel

[Adafruit I2C Stemma QT Rotary Encoder Breakout with NeoPixel](https://www.adafruit.com/product/4991)
Rotary encoders are soooo much fun! Twist em this way, then twist them that way. Unlike potentiometers, they go all the way around and often have little detents for tactile feedback. But, if you've ever tried to add encoders to your project you know that they're a real challenge to...

In Stock
[Buy Now](https://www.adafruit.com/product/4991)
[Related Guides to the Product](https://learn.adafruit.com/products/4991/guides)
![Top view video of a hand turning the rotary encoder knobs on three PCBs. The NeoPixel LEDs on each PCB change color. The OLED display changes its readout data with each twisty-turn.](https://cdn-shop.adafruit.com/product-videos/640x480/4991-08.jpg)

### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long

[STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210)
This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4210)
[Related Guides to the Product](https://learn.adafruit.com/products/4210/guides)
![Angled shot of STEMMA QT / Qwiic JST SH 4-pin Cable.](https://cdn-shop.adafruit.com/640x480/4210-00.jpg)

### Panel Mount 2.1mm DC barrel jack

[Panel Mount 2.1mm DC barrel jack](https://www.adafruit.com/product/610)
This power jack is designed to easily attach to a panel up to 8mm thick (0.315" or 5/16") and fit 2.1mm power plugs snugly and securely. Perfect for adding a power connector to your project enclosure. We like this jack in particular for its long body (so you can use it on thicker...

In Stock
[Buy Now](https://www.adafruit.com/product/610)
[Related Guides to the Product](https://learn.adafruit.com/products/610/guides)
![Angled Front Shot of the Panel Mount 2.1mm DC barrel jack.](https://cdn-shop.adafruit.com/640x480/610-08.jpg)

### Part: Anodized Aluminum Machined Knob
quantity: 1
20mm Diameter
[Anodized Aluminum Machined Knob](https://www.adafruit.com/product/5527)

### Part: 9 VDC 1000mA regulated switching power adapter
quantity: 1
UL listed
[9 VDC 1000mA regulated switching power adapter](https://www.adafruit.com/product/63)

### Part: Bolt-On Kit
quantity: 1
M3 screws
[Bolt-On Kit](https://www.adafruit.com/product/3816)

### Part: Stacking Headers for Feather
quantity: 1
12-pin and 16-pin female headers
[Stacking Headers for Feather](https://www.adafruit.com/product/2830)

### Part: Pre-Cut Multi-Colored Heat Shrink Pack Kit
quantity: 1
280 pcs
[Pre-Cut Multi-Colored Heat Shrink Pack Kit](https://www.adafruit.com/product/4559)

### Part: Premium Silicone Covered Extension Jumper Wires
quantity: 1
200mm x 40
[Premium Silicone Covered Extension Jumper Wires](https://www.adafruit.com/product/4635)

# Darth Faders

## Build the Darth Faders

![](https://cdn-learn.adafruit.com/assets/assets/000/115/578/medium800/3d_printing_darth-9175.jpg?1664747913)

The basic circuit for Darth Faders is pretty simple -- you'll drive the three faders using a Motor FeatherWing plugged into a Feather RP2040 running CircuitPython. A Terminal Block FeatherWing will help make the many wired connections.

A rotary encoder with push button will be used to change modes and flip between animation poses.

Power to the Feather comes from USB-C and a 9VDC wall wart will power the Motor FeatherWing.

An optional set of 1MΩ resistors will allow you to use the fader touch encoders should you decide to add code for such functionality.

![](https://cdn-learn.adafruit.com/assets/assets/000/115/520/medium800/3d_printing_darthf_fritz.jpg?1664662468)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/519/medium800/3d_printing_drthf_fritz2.jpg?1664662430)

## Wiring Connections

These are the connections you'll wire:

- Fader +V to Feather 3V
- Fader GND to Feather GND
- Fader motor pins to Motor FeatherWing pins (polarity doesn't matter, you'll set direction in code)
- DC plug center pin to Motor FeatherWing power + terminal
- DC plug sleeve pin to Motor FeatherWing power - terminal
- Rotary encoder breakout I2C via STEMMA QT to Feather STEMMA QT

Optional:

- Fader touch pin (per fader) to Feather D12, D11, D10, with 1MΩ resistor to Feather GND per pin

## Fader Wiring

Wire the connections for all three faders as shown. You can use any wiring you like, the use of silicone wiring with Dupont connectors is the deluxe option!

![3d_printing_darth-9214.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/528/medium640/3d_printing_darth-9214.jpg?1664741796)

![3d_printing_darth-9213.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/529/medium640/3d_printing_darth-9213.jpg?1664741806)

![3d_printing_flyingfad-8303.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/531/medium640/3d_printing_flyingfad-8303.jpg?1664742028)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/530/medium800/3d_printing_darth-9215.jpg?1664741821)

## Terminal Block FeatherWing

You can wire directly from the faders to the terminal blocks for the power, ground, potentiometer, and optional cap touch wires. Again, short Dupont cables were used here to simplify the connections.

![3d_printing_darth-9216.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/532/medium640/3d_printing_darth-9216.jpg?1664742100)

![3d_printing_darth-9217.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/533/medium640/3d_printing_darth-9217.jpg?1664742108)

## Feather RP2040 Prep

Solder in a set of stacking headers on the Feather. This way, it can plug into the Terminal Block FeatherWing and then the Motor FeatherWing can plug into the Feather.

You can also plug the STEMMA QT cable into the Feather at this time. This will be used to connect the rotary encoder breakout.

![3d_printing_darth-9211.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/534/medium640/3d_printing_darth-9211.jpg?1664745521)

![3d_printing_darth-9210.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/535/medium640/3d_printing_darth-9210.jpg?1664745538)

## Motor FeatherWing Prep

Solder in the terminal blocks as shown in the Motor FeatherWing instructions here.

If you plan to use Dupont cables, you can screw them in as shown -- this will simplify the connections later during assembly.

![3d_printing_darth-9209.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/536/medium640/3d_printing_darth-9209.jpg?1664745674)

## Circuit Assembly

Plug the Feather into the Terminal Block FeatherWing.

Then, plug all of your fader wiring into the Motor FeatherWing and the Terminal Block FeatherWing as shown in the Fritzing diagram (and these photos).

Finally, plug the Motor FeatherWing onto the Feather.

![3d_printing_darth-9206.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/537/medium640/3d_printing_darth-9206.jpg?1664745754)

![3d_printing_darth-9207.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/538/medium640/3d_printing_darth-9207.jpg?1664745763)

# Darth Faders

## 3D Printed Enclosure

The Darth Faders enclosure is made of three models you'll need to 3D print. There is a base to hold the electronics, wall body to house the faders, power plug, and rotary encoder, and the cap.

They are straightforward prints, requiring no support.

![](https://cdn-learn.adafruit.com/assets/assets/000/115/517/medium800/3d_printing_darthfader0.jpg?1664661565)

The model files you'll need to build your Darth Faders are linked here:

[Darth Faders 3D model files](https://www.thingiverse.com/thing:5541123)
![](https://cdn-learn.adafruit.com/assets/assets/000/115/515/medium800/3d_printing_darthfader2.jpg?1664661540)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/516/medium800/3d_printing_darthfader1.jpg?1664661558)

# Darth Faders

## Assembly

## Base

Fit the FeatherWing/Feather/FeatherWing sandwich onto the pegs on the base as shown.

![3d_printing_darth-9205.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/540/medium640/3d_printing_darth-9205.jpg?1664746727)

![3d_printing_darth-9203.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/541/medium640/3d_printing_darth-9203.jpg?1664746773)

Loosely fit the three faders into their slots in the base as shown, then screw three M3 screws into the front of the base and into their respective threaded holes in the three faders.

![](https://cdn-learn.adafruit.com/assets/assets/000/115/550/medium800/3d_printing_darth-9202.jpg?1664746836)

Warning: 

![](https://cdn-learn.adafruit.com/assets/assets/000/115/551/medium800/3d_printing_darth-9189.jpg?1664746958)

## Encoder Prep

Screw on the spacers and nuts as shown. This will provide proper spacing to attach to the inside of the walls.

![3d_printing_darth-9201.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/552/medium640/3d_printing_darth-9201.jpg?1664747045)

![3d_printing_darth-9200.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/553/medium640/3d_printing_darth-9200.jpg?1664747053)

## Mount Encoder

Attach the encoder from the inside of the printed enclosure as shown.

![3d_printing_darth-9199.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/554/medium640/3d_printing_darth-9199.jpg?1664747109)

![3d_printing_darth-9198.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/555/medium640/3d_printing_darth-9198.jpg?1664747117)

## Power Plug

You'll provide 9VDC power to the Motor FeatherWing using a wall wart. Prep a DC jack with short wires as shown to connect to the terminals on the FeatherWing.

Push the plug through the enclosure and then fasten with the provided nut.

![3d_printing_darth-9197.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/556/medium640/3d_printing_darth-9197.jpg?1664747200)

![3d_printing_darth-9196.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/557/medium640/3d_printing_darth-9196.jpg?1664747214)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/558/medium800/3d_printing_darth-9195.jpg?1664747312)

## Connect Power

Mind the polarity and connect the DC power connector to the Motor FeatherWing's power terminals.

![3d_printing_darth-9194.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/559/medium640/3d_printing_darth-9194.jpg?1664747340)

![3d_printing_darth-9193.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/560/medium640/3d_printing_darth-9193.jpg?1664747411)

## Enclose

Slide the walls over the wiring and into the base. If you hadn't already screwed in the faders, do so now.

![3d_printing_darth-9192.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/561/medium640/3d_printing_darth-9192.jpg?1664747424)

![3d_printing_darth-9191.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/562/medium640/3d_printing_darth-9191.jpg?1664747440)

![3d_printing_darth-9190.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/563/medium640/3d_printing_darth-9190.jpg?1664747457)

![3d_printing_darth-9189.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/564/medium640/3d_printing_darth-9189.jpg?1664747466)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/565/medium800/3d_printing_darth-9188.jpg?1664747514)

## Connect Encoder

Plug the STEMMA QT cable from the Feather into the rotary encoder.

![3d_printing_darth-9187.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/566/medium640/3d_printing_darth-9187.jpg?1664747527)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/567/medium800/3d_printing_darth-9186.jpg?1664747567)

## Cap It

Place the cap over the enclosure, then screw in the remaining three screws to connect the faders to the cap.

![3d_printing_darth-9185.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/568/medium640/3d_printing_darth-9185.jpg?1664747584)

![3d_printing_darth-9184.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/569/medium640/3d_printing_darth-9184.jpg?1664747592)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/570/medium800/3d_printing_darth-9182.jpg?1664747651)

## Encoder Knob

Place the knob over the encoder shaft, making sure to leave enough space between the knob and the enclosure for the push encoder shaft to travel when pressed.

Tighten the grub screw with a hex wrench.

![3d_printing_darth-9181.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/571/medium640/3d_printing_darth-9181.jpg?1664747668)

![3d_printing_darth-9180.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/572/medium640/3d_printing_darth-9180.jpg?1664747684)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/575/medium800/3d_printing_darth-9176.jpg?1664747826)

## Outside Connections

Plug in USB-C to the Feather and DC power. You are ready to code and use the Darth Faders.

![3d_printing_darth-9178.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/573/medium640/3d_printing_darth-9178.jpg?1664747770)

![3d_printing_darth-9177.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/574/medium640/3d_printing_darth-9177.jpg?1664747777)

Primary: 

![](https://cdn-learn.adafruit.com/assets/assets/000/115/576/medium800/3d_printing_darth-9179.jpg?1664747887)

![](https://cdn-learn.adafruit.com/assets/assets/000/115/577/medium800/3d_printing_darth-9175.jpg?1664747899)

# Darth Faders

## Install CircuitPython

[CircuitPython](https://github.com/adafruit/circuitpython) is a derivative of [MicroPython](https://micropython.org) designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the **CIRCUITPY** drive to iterate.

## CircuitPython Quickstart

Follow this step-by-step to quickly get CircuitPython running on your board.

[Download the latest version of CircuitPython for this board via circuitpython.org](https://circuitpython.org/board/adafruit_feather_rp2040/)
 **Click the link above to download the latest CircuitPython UF2 file.**

Save it wherever is convenient for you.

![install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/655/medium640/install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg?1618943202)

![](https://cdn-learn.adafruit.com/assets/assets/000/102/705/medium800/adafruit_products_FeatherRP_buttons_highlighted.jpg?1623167565)

To enter the bootloader, hold down the **BOOT/**** BOOTSEL button**(highlighted in red above), and while continuing to hold it (don't let go!), press and release the**reset button**(highlighted in red or blue above).&nbsp;**Continue to hold the BOOT/BOOTSEL button until the RPI-RP2 drive appears!**

If the drive does not appear, release all the buttons, and then repeat the process above.

You can also start with your board unplugged from USB, press and hold the BOOTSEL button (highlighted in red above), continue to hold it while plugging it into USB, and wait for the drive to appear before releasing the button.

A lot of people end up using charge-only USB cables and it is very frustrating! **Make sure you have a USB cable you know is good for data sync.**

You will see a new disk drive appear called **RPI-RP2**.

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **RPI-RP2.**

![install_circuitpython_on_rp2040_RP2040_bootloader_drive.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/656/medium640/install_circuitpython_on_rp2040_RP2040_bootloader_drive.jpg?1618943666)

![install_circuitpython_on_rp2040_RP2040_drag_UF2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/657/medium640/install_circuitpython_on_rp2040_RP2040_drag_UF2.jpg?1618943674)

The **RPI-RP2** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

That's it, you're done! :)

![install_circuitpython_on_rp2040_RP2040_CIRCUITPY.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/658/medium640/install_circuitpython_on_rp2040_RP2040_CIRCUITPY.jpg?1618943864)

## Safe Mode

You want to edit your **code.py** or modify the files on your **CIRCUITPY** drive, but find that you can't. Perhaps your board has gotten into a state where **CIRCUITPY** is read-only. You may have turned off the **CIRCUITPY** drive altogether. Whatever the reason, safe mode can help.

Safe mode in CircuitPython does not run any user code on startup, and disables auto-reload. This means a few things. First, safe mode _bypasses any code in_ **boot.py** (where you can set **CIRCUITPY** read-only or turn it off completely). Second, _it does not run the code in_ **code.py**. And finally, _it does not automatically soft-reload when data is written to the_ **CIRCUITPY** _drive_.

Therefore, whatever you may have done to put your board in a non-interactive state, safe mode gives you the opportunity to correct it without losing all of the data on the **CIRCUITPY** drive.

### Entering Safe Mode
To enter safe mode when using CircuitPython, plug in your board or hit reset (highlighted in red above). Immediately after the board starts up or resets, it waits 1000ms. On some boards, the onboard status LED (highlighted in green above) will blink yellow during that time. If you press reset during that 1000ms, the board will start up in safe mode. It can be difficult to react to the yellow LED, so you may want to think of it simply as a slow double click of the reset button. (Remember, a fast double click of reset enters the bootloader.)

### In Safe Mode

If you successfully enter safe mode on CircuitPython, the LED will intermittently blink yellow three times.

If you connect to the serial console, you'll find the following message.

```terminal
Auto-reload is off.
Running in safe mode! Not running saved code.

CircuitPython is in safe mode because you pressed the reset button during boot. Press again to exit safe mode.

Press any key to enter the REPL. Use CTRL-D to reload.
```

You can now edit the contents of the **CIRCUITPY** drive. Remember, _your code will not run until you press the reset button, or unplug and plug in your board, to get out of safe mode._

## Flash Resetting UF2

If your board ever gets into a really _weird_ state and CIRCUITPY doesn't show up as a disk drive after installing CircuitPython, try loading this 'nuke' UF2 to RPI-RP2. which will do a 'deep clean' on your Flash Memory. **You will lose all the files on the board** , but at least you'll be able to revive it! After loading this UF2, follow the steps above to re-install CircuitPython.

[Download flash erasing "nuke" UF2](https://cdn-learn.adafruit.com/assets/assets/000/101/659/original/flash_nuke.uf2?1618945856)
# Darth Faders

## Code the Darth Faders

## Text Editor

Adafruit recommends using the **Mu** editor for editing your CircuitPython code. You can get more info in [this guide](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

Alternatively, you can use any text editor that saves simple text files.

## Download the Project Bundle

Your project will use a specific set of CircuitPython libraries, plus the&nbsp; **code.py** &nbsp;file. To get everything you need, click on the&nbsp; **Download Project Bundle** &nbsp;link below, and uncompress the .zip file.

Drag the contents of the uncompressed bundle directory onto your board's **CIRCUITPY** &nbsp;drive, replacing any existing files or directories with the same names, and adding any new ones that are necessary.

https://youtu.be/PRO9oYsu4BI

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Darth_Faders/code.py

## How It Works

The Darth Faders have two modes -- free running where the faders will move to different predefined positions continuously, and per-pose mode where the rotary encoder switches from pose to pose.&nbsp;

The motorized slide pots act as linear actuators with servo control -- there is a feedback loop where the motor moves the slide which changes the analog read value of the potentiometer's resistance. This is what allows you to send a fader to a specific position.

## Libraries

You'll import libraries to provide functionality in the code:

- **time**
- **board**
- **analogio**
- **adafruit\_debouncer**
- **adafruit\_motorkit**
- **adafruit\_seesaw**

```auto
import time
import board
import analogio
from adafruit_debouncer import Debouncer
from adafruit_motorkit import MotorKit
from adafruit_seesaw import seesaw, rotaryio, digitalio
```

## Motors

The fader motors are controlled by the motor FeatherWing via I2C. Here's the setup:

```auto
num_faders = 3

motorwing = MotorKit(i2c=board.I2C())
motorwing.frequency = 122  # tune this 50 - 200 range
max_throttle = 0.18  # tune this 0.2 - 1 range

# make arrays for all the things we care about
motors = [None] * num_faders
faders = [None] * num_faders
faders_pos = [None] * num_faders
last_faders_pos = [None] * num_faders

# set up motors in motor array
motors[0] = motorwing.motor1
motors[1] = motorwing.motor2
motors[2] = motorwing.motor3

# set motors to "off"
for i in range(num_faders):
    motors[i].throttle = None
```

The PWM frequency and throttle values allow you to find the right balance between smoothness and speed (more on tuning PWM for DC motors&nbsp;[in this guide](https://learn.adafruit.com/improve-brushed-dc-motor-performance/overview)).

## Rotary Encoder

The STEMMA QT Rotary Encoder breakout runs on a seesaw chip and communicates via I2C. The push encoder button is set up with debouncer.

```auto
# STEMMA QT Rotary encoder setup
seesaw = seesaw.Seesaw(board.I2C(), addr=0x36)  # default address is 0x36
seesaw.pin_mode(24, seesaw.INPUT_PULLUP)
button_in = digitalio.DigitalIO(seesaw, 24)
button = Debouncer(button_in)
encoder = rotaryio.IncrementalEncoder(seesaw)
last_encoder_pos = 0
```

## Fader Analog Read

The three slide potentiometers are set up on analog read pins and their raw values are re-mapped to 0-255.

```auto
# set up faders
fader_pins = (board.A0, board.A1, board.A2)
for i in range(num_faders):
    faders[i] = analogio.AnalogIn(fader_pins[i])
    faders_pos[i] = faders[i].value // 256  # make it 0-255 range
    last_faders_pos[i] = faders_pos[i]
```

## Position Function

Whenever the faders need to move, this `update_positions()` function is called with the arguments for which fader, what position, and the speed.

```auto
def update_position(fader, new_position, speed):
    global faders_pos  # pylint: disable=global-statement
    faders_pos[fader] = int(faders[fader].value//256)

    if abs(faders_pos[fader] - new_position) &gt; 2 :
        if faders_pos[fader] &gt; new_position :
            motors[fader].throttle = speed
        if faders_pos[fader] &lt; new_position:
            motors[fader].throttle = speed * -1
        faders_pos[fader] = int(faders[fader].value//256)
    if faders_pos[fader] == new_position:
        motors[fader].throttle = None
```

## Animation List

We can treat the positions sort of like poses in an animation or values in a sequence. Each fader has a list of positions, these are used when calling the `update_position()` function.

```auto
# pre-saved positions for the buttons to call
H = 240  # high
M = 127  # mid
L = 10  # low

# create custom animation patterns here:
saved_positions = (
                    (M, H, L, L, H, M, L),  # fader 1
                    (M, H, L, H, H, M, L),  # fader 2
                    (M, L, L, H, H, M, L)  # fader 3
)


num_positions = len(saved_positions[0])  # how many moves in our move list
position = 0  # which column of our 'saved_position' move list we're currently on

last_time = time.monotonic()
period = 4  # time in seconds between new desitnation picks
```

## Main Loop

The main loop checks for encoder button presses to change between the two modes, then it checks to see if the encoder has been turned to switch from pose-to-pose.

If the move state is true, the `update_position()` function is called, and after the pre-set period is complete it moves on to the next one in the list.

```auto
while True:
    button.update()
    if button.fell:
        move_state = not move_state
        print("move_state is " + str(move_state))
        if not move_state:
            for i in range(num_faders):
                motors[i].throttle = None

    # always move all motors toward destinations
    for i in range(num_faders):
        update_position(i, saved_positions[i][position], max_throttle)

    # has encoder been turned?
    encoder_pos = -encoder.position
    if encoder_pos != last_encoder_pos:
        encoder_delta = encoder_pos - last_encoder_pos
        last_encoder_pos = encoder_pos

    # if we are not moving automatically, allow encoder tuning animation frames
    if not move_state:
        if encoder_delta:  # encoder was turned
            direction = 1 if (encoder_delta &gt; 0) else -1 # which direction encoder was turned
            position = (position + direction) % num_positions  # increment/decrement
        encoder_delta = 0

    # else we are moving automatically
    if move_state:
        # if it is time to go to a new destination, do it
        if time.monotonic() - last_time &gt; period:  # after 'period' seconds, change
            last_time = time.monotonic()
            position = (position + 1) % num_positions
```


## Featured Products

### Motorized Slide Potentiometer - 10KΩ Linear with 5V DC Motor

[Motorized Slide Potentiometer - 10KΩ Linear with 5V DC Motor](https://www.adafruit.com/product/5466)
This linear slide potentiometer comes with an added&nbsp;_kick_&nbsp;- its [not just a plain old slide pot](https://www.adafruit.com/?q=slide+pot&sort=BestMatch)! Underneath is mounted a slim geared DC motor that can gently move the wiper up and down, without human...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5466)
[Related Guides to the Product](https://learn.adafruit.com/products/5466/guides)
### DC Motor + Stepper FeatherWing Add-on For All Feather Boards

[DC Motor + Stepper FeatherWing Add-on For All Feather Boards](https://www.adafruit.com/product/2927)
A Feather board without ambition is a Feather board without FeatherWings! This is the&nbsp; **DC Motor + Stepper&nbsp;FeatherWing** which will let you use 2 x bi-polar stepper motors or 4 x brushed DC motors (or 1 stepper and 2 DC motors). Using our <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/2927)
[Related Guides to the Product](https://learn.adafruit.com/products/2927/guides)
### Adafruit Feather RP2040

[Adafruit Feather RP2040](https://www.adafruit.com/product/4884)
A new chip means a new Feather, and the Raspberry Pi RP2040 is no exception. When we saw this chip we thought "this chip is going to be awesome when we give it the Feather Treatment" and so we did! This Feather features the&nbsp; **RP2040** , and all niceties you know and...

In Stock
[Buy Now](https://www.adafruit.com/product/4884)
[Related Guides to the Product](https://learn.adafruit.com/products/4884/guides)
### Adafruit I2C Stemma QT Rotary Encoder Breakout with NeoPixel

[Adafruit I2C Stemma QT Rotary Encoder Breakout with NeoPixel](https://www.adafruit.com/product/4991)
Rotary encoders are soooo much fun! Twist em this way, then twist them that way. Unlike potentiometers, they go all the way around and often have little detents for tactile feedback. But, if you've ever tried to add encoders to your project you know that they're a real challenge to...

In Stock
[Buy Now](https://www.adafruit.com/product/4991)
[Related Guides to the Product](https://learn.adafruit.com/products/4991/guides)
### Assembled Terminal Block Breakout FeatherWing for all Feathers

[Assembled Terminal Block Breakout FeatherWing for all Feathers](https://www.adafruit.com/product/2926)
The&nbsp;Terminal Block Breakout FeatherWing kit is like the Golden Eagle of prototyping FeatherWings (eg. majestic, powerful, good-looking). To start, you get a nice prototyping area underneath your Feather, with extra pads for ground, 3.3V and SDA/SCL. Not one to stop there, we expanded the...

In Stock
[Buy Now](https://www.adafruit.com/product/2926)
[Related Guides to the Product](https://learn.adafruit.com/products/2926/guides)
### Panel Mount 2.1mm DC barrel jack

[Panel Mount 2.1mm DC barrel jack](https://www.adafruit.com/product/610)
This power jack is designed to easily attach to a panel up to 8mm thick (0.315" or 5/16") and fit 2.1mm power plugs snugly and securely. Perfect for adding a power connector to your project enclosure. We like this jack in particular for its long body (so you can use it on thicker...

In Stock
[Buy Now](https://www.adafruit.com/product/610)
[Related Guides to the Product](https://learn.adafruit.com/products/610/guides)
### 9 VDC 1000mA regulated switching power adapter - UL listed

[9 VDC 1000mA regulated switching power adapter - UL listed](https://www.adafruit.com/product/63)
This is a really nice power supply. It's a switching DC supply so it's small and light and efficient. It is thin so it fits in power strips without blocking other outlets. The output is regulated so you'll get a steady 9V up to 1000mA (1 Amp) of current draw. 5.5mm/2.1mm barrel...

In Stock
[Buy Now](https://www.adafruit.com/product/63)
[Related Guides to the Product](https://learn.adafruit.com/products/63/guides)
### Circuit Playground Bolt-On Kit

[Circuit Playground Bolt-On Kit](https://www.adafruit.com/product/3816)
You have a [Circuit Playground Express](https://www.adafruit.com/product/3333), but you need to mount it to your&nbsp;charming cardboard robot friend, eh? Not so easy if you don't have a set of standoffs!&nbsp;  
  
In this kit comes:

- 6 x M3 12mm brass hexagonal...

In Stock
[Buy Now](https://www.adafruit.com/product/3816)
[Related Guides to the Product](https://learn.adafruit.com/products/3816/guides)

## Related Guides

- [Adafruit Stepper + DC Motor FeatherWing](https://learn.adafruit.com/adafruit-stepper-dc-motor-featherwing.md)
- [Introducing Adafruit Feather RP2040](https://learn.adafruit.com/adafruit-feather-rp2040-pico.md)
- [Adafruit I2C QT Rotary Encoder](https://learn.adafruit.com/adafruit-i2c-qt-rotary-encoder.md)
- [32x32 Square Pixel Art Animation Display](https://learn.adafruit.com/32x32-square-pixel-display.md)
- [Pip-Boy 2040 Wrist-Mounted Prop](https://learn.adafruit.com/pip-boy-2040.md)
- [Flying Faders](https://learn.adafruit.com/flying-faders.md)
- [Build an ESP8266 Mobile Robot](https://learn.adafruit.com/build-an-esp8266-mobile-robot.md)
- [Driving TM1814 addressable LEDs](https://learn.adafruit.com/driving-tm1814-addressable-leds.md)
- [Deco Two-Key Feather Macro Pad](https://learn.adafruit.com/deco-two-key-keypad-macropad-circuitpython-feather.md)
- [Program RP2040 in Arduino](https://learn.adafruit.com/rp2040-arduino-with-the-earlephilhower-core.md)
- [Magic Band Reader](https://learn.adafruit.com/magic-band-reader.md)
- [Optical Sensor Drum Track Sequencer](https://learn.adafruit.com/drum-track-sequencer.md)
- [CircuitPython Hardware: PCA9685 DC Motor & Stepper Driver](https://learn.adafruit.com/micropython-hardware-pca9685-dc-motor-and-stepper-driver.md)
- [My Mini Race Car](https://learn.adafruit.com/my-mini-race-car.md)
- [Adafruit Floppy FeatherWing with 34-Pin IDC Connector](https://learn.adafruit.com/adafruit-floppy-featherwing-with-34-pin-idc-connector.md)
- [Motorized POV LED Display](https://learn.adafruit.com/motorized-pov-led-display.md)
- [Discord and Slack Connected Smart Plant with Adafruit IO Actions](https://learn.adafruit.com/discord-and-slack-connected-smart-plant-with-adafruit-io-triggers.md)
- [Remote Effects Trigger Box](https://learn.adafruit.com/remote-effects-trigger.md)
