Normally lurking unseen inside stereo systems, the digital potentiometer needs no adjustment, because it adjusts itself. Its fluctuating resistance can change the color or brightness of a light, the loudness or frequency of a sound, or any other parameters that depend on voltage and current.
Sealed inside the chip is a ladder of resistors. Figure A shows the idea. The connections between the resistors are called “taps.” If you have 127 resistors (as in this example), there are 128 possible taps, including those at the ends of the ladder. Digital potentiometers typically have 8, 16, 32, 64, 100, 128, 256, or 1,024 taps.
Two pins with the remarkably unimaginative names “A” and “B” provide access to the ends of the ladder, while a third pin, known as the Wiper, can be connected internally with any of the taps. Although the resistance between the Wiper and A or B changes in small, discrete steps, the transition is smooth enough for many purposes, such as adjusting the volume on a stereo.
Figure B shows the pinouts of the AD5220 family of digital potentiometers (which include the AD5220BNZ10, AD5220BNZ50, and AD5220BNZ100, having a total internal resistance of 10K, 50K, and 100K respectively). Pulses at the Clock pin move the Wiper connection one step at a time, while the logic state of the Up/Down pin determines whether the Wiper will advance toward A or B. The Chip Select pin must be grounded to activate the chip.
The AD5220 needs a 5VDC power supply, which you can provide using an LM7805 voltage regulator with a 9V battery. A and B are functionally identical, so you can apply voltage either way around, but the potential difference must never exceed 5V.
NOTE: You can also buy digital potentiometers in which each resistor has a numeric address, and a binary code tells the Wiper to jump directly to that address. However, this requires a serial communications protocol that is too complicated for me to deal with here.
If you control the chip using pushbuttons, you’ll have to debounce them to get rid of their voltage spikes. However, it’s easier (and more interesting) to control the chip electronically, and I suggest using an Intersil 7555 for this purpose. A plain old 555 timer creates voltage spikes, which the digital pot may misinterpret as clock pulses.
Figure C shows a test circuit in which I connected the ends of the resistor ladder (pins 3 and 6 of the AD5220) between the power supply and ground. As the Wiper moves between them, its voltage (on pin 5) will vary between 0V and 5VDC.
Begin with the red LED disconnected. Power up, and the yellow LED should flicker to confirm that the timer is sending pulses. The AD5220 always starts with the Wiper in the center of its range, and the Wiper voltage will gradually increase, because the Up/Down pin (pin 2) is connected through a 10K resistor to ground. You’ll see your meter displaying the voltage as the Wiper climbs the ladder. Now hold down the pushbutton to connect pin 2 with 5VDC, and the output will count down almost to 0V (the actual value will depend on the internal resistance of your power supply).
Connect the red LED in parallel with your meter, press the button to make the chip count down, and the LED fades out completely around 1.6VDC. This happens because an LED, like any diode, requires a minimum voltage to function at all. I specified a red LED because it requires less forward voltage than other colors. A white LED, for instance, requires at least 3.2VDC. (These useful facts, and many more, are contained in my Encyclopedia of Electronic Components, Volume 2, which is available now at the Maker Shed and fine bookstores.)
If you want the LED to remain dimly visible at the low end of the range, you need to add a resistor between pin 3 of the digital potentiometer and ground. And while you’re at it, add a transistor, because we shouldn’t really drive the AD5220 so close to its maximum rating of 20mA.
Figure D shows the lower half of the previous circuit rewired for this purpose. A 6.8K resistor now gives the Wiper a minimum of around 2VDC instead of 0V. This should stop the LED from going completely dark. Also, the series resistor for the red LED has been changed from 220 ohms to 100 ohms, because the transistor adds some effective resistance to the circuit. The current through my LED maxes out at 18mA and drops almost to 0mA. Use your meter to check if yours does the same. Now substitute a 1µF timing capacitor for the 10µF timing capacitor, and the LED should fade in and out quickly and smoothly.
Let’s replace the pushbutton with something that will reverse the cycle automatically. The output from another (slower) timer could be applied to the Up/Down pin, but it would tend to drift out of sync with the first timer. What we need is a component that counts 128 cycles, then reverses the state of the Up/Down pin, counts another 128 cycles, reverses it again — and so on.
That sounds like a job for a counter chip! In fact an 8-bit binary counter runs through 256 cycles, which just happens to be 2 x 128. After the first 128 steps, the output changes from 01111111 to 10000000, so the most-significant-bit pin goes from low to high. It then stays high for another 128 cycles, at which point it changes from high to low. Just the thing! This is why I chose a digital potentiometer that has 128 taps, so we could make it step up and down with an 8-bit timer.
The final circuit and schematic are shown in Figure E, using a 74HC4520 timer chip, which contains two 4-bit counters, chained together. All of its outputs are unconnected except for the most-significant-bit pin.
Build two additional copies of this circuit, one driving a green LED and the other driving a blue LED. Adjust the speed of the timers so that they are slightly out of phase. Now if you mix the light from the LEDs, it will run through all the colors of the spectrum in a pattern that seems random. You will have to increase the value for the 6.8K resistor for the green LED, so that the minimum voltage of the Wiper matches the minimum forward voltage of the LED. You’ll need to do the same for the blue LED. This will be a matter of trial and error.
So far so good — but I’m only getting started. How about audio effects? Wire a 555 timer to run at an audio frequency. Instead of its timing resistor, insert a digital potentiometer (with a 5K additional series resistor, so that the total value never goes to zero). Add the 8-bit binary counter as before, and now you have a rising and falling musical tone.
The up-and-down cycle will quickly become boring, but my book Make: More Electronics tells you how to build a simple linear-feedback shift register (LFSR) to create a pseudo-random output of high and low states. Substitute this for the counter at the Up/Down pin of the digital potentiometer, and you’ll have automated electronic music that sounds totally unpredictable. Alternatively, use the LFSR to add more randomness to your lighting circuit.
Other options are possible. The 10K version of the AD5220 can run at up to 650kHz. If you run it, conservatively, at 300kHz, it will cycle all the way up and all the way down almost 1,200 times per second. Since 1.2kHz is an audible frequency, you can connect the fluctuating output from the digital pot through an amplifier to a loudspeaker, and hear a very precise triangular sound wave. In the timer that sets the frequency, remove the timing resistor, substitute another digital potentiometer, control it with an LFSR, and you’ll get a very different kind of random music.
Of course, digital potentiometers were never intended for this kind of weirdness. But that’s what makes it so much fun.
We'll assume you're ok with this, but you can opt-out if you wish.