Here’s an example project to control a Neopixel strip with input from a rotary potentiometer (pot). I used a diffuse pixel strip, like this one.
I did this example with an ESP32C3 module. Use the Analog to Digital converter of the ESP32 to read voltage from the potentiometer. The ESP32 ACD does not read all the way up to 3.3 V, so I added a 2k Ohm resistor so that the analog pin attached to the pot wiper (central pin) ranged from 0V (couterclockwise) to about 2.7V (clockwise).
Neopixel wired to an esp32 breadboard with potentiometer
Circuit for neopixels and poentiometer on esp32 board.
Below is the code to run one neopixel strip with one pot. The code sets up the ADC with the maximum range, and asks for a 12-bit reading ( 0 to 4096). Pot wiper is on pin 2, and LED pixel strip is attached to pin 20. See pinout. This code just lights one pixel at a time, depending on the pot position.
Here’s a video, with one pot and one pixel strip, wired up on the breadboard.
Projects made with wires plugged into breadboards don’t last very long! One way to solidify a project is to solder to a printed circuitboard of some kind. Here, I have used a design that our friends at MIT have made, as part of the Modular Things project. There are several designs that include a xiao module microcontroller and other components to make modules with a variety of functions. One of the boards for modular things is a general-purpose breadboard-board, documented here. To make a bunch of these boards, I sent the design, in the form of Gerber files on the above-linked website, to a board house. Cost, about a dollar per board for quantity fifty. I soldered connections to this
The figure to the right is from the design files for the breadboard-board. It shows the connections. Components are soldered into the plated through-holes, and jumper wires are soldered in to complete the connections.
Below is the board, shown front and back, with the xiao ESP32 module, connections for the LED strips (three large wires) and potentiometer leads (smaller blue/white wires).
Another code for a Neopixel strip, this time with the pixel pattern generated through code. No external inputs. The loop uses nested variables i and j in a simple way to generate a pattern of colors and movement that you might not anticipate after looking at the code. Or maybe you would.
More things to do with Pixel strips. I added a second potentiometer and connections for a second Neopixel strip. Here’s the board and connections: