Digital potentiometers and pitch tracking with the arduino


#1

Hi everyone,
Couple of general questions-- I want to use the arduino as a sort of “digital potentiometer”, controlling the resistance to a couple of oscillator circuits. In this way I can control pitch and amplitude of the oscillators from a data set. I have an arduino Uno, and I know that it doesn’t have any analogue outputs, just PWM, but perhaps this is ok? or maybe there is an indirect way to go about this? either by converting the PWM or ? Sorry, I cant be more specific at this moment.

On a completely seperate idea— I would like to write a program that tunes a (guitar) string. My big wonder is if there is a library that will allow me to track frequency/pitch of the string? Or would this be something I would have to use Max/maxuino for? I’m trying to keep it as simple as possible so doing this without some external software would be great!

Thanks all.


#2

So, you can’t really use the Arduino as a “digital potentiometer” directly … but you can control a “digital potentiometer” integrated chip (IC) using the arduino. Here is an example https://www.sparkfun.com/products/10613. If you buy them in bulk you can get them much cheaper (e.g. https://www.digikey.com/product-detail/en/MCP4131-103E%2FP/MCP4131-103E%2FP-ND/1874338)

Guitar – Yes, totally possible. Basically you need to control a motor (probably a stepper motor) and create a feedback loop (sometimes called a PID loop see this video and this example for the gist of PID also @jetonski is a local PID legend). Then you can write a simple pitch detector in the language of your choice (I’ve got code around for doing it in Max, Processing and openFrameworks) and then you’ll communicate with an arduino to turn the stepper motor in the right direction. If you got really sophisticated, you could probably do this without a computer using a Teensy … but prototype with a computer … :slight_smile: Keep in mind that because of the high tension of a guitar string, you may find it easiest to hack an actual guitar and make the motor turn the OR attach a motor to a tuning machine head (e.g. http://www.guitarcenter.com/Tuning-Machine-Heads.gc). Without those gears, most motors won’t have enough torque or resolution to tune a guitar in any meaningful way. It really depends on if you want to make your own resonating chamber, or if you’re going to use an electric guitar pickup, etc … it’s all style. For making the sound, you could either mechanically pluck it with a motor and a cam (e.g. https://en.wikipedia.org/wiki/Camshaft) or use a solenoid to hammer-on (push solenoid) or pluck (pull solenoid) (google self-playing guitar or robotic guitar lots of examples) – OR if you are using an electric guitar and you’re going for ethereal there’s always the good old ebow ( https://www.youtube.com/watch?v=WREXBGgA26A ).

OK, brain dump you got me excited. :slight_smile:


#3

Chris already broached the topic but you can also get higher resolution out of “hardware” digital potentiometer rather than trying to utilize the arduino as an analog equivalent

As for tuning, Couldn’t you use FFT analysis to get the pitch? You could have it read out to an LCD, LEDS, or some meaningful representation for your project. You can run FFT on a teensy and honestly I can imagine something as tiny as an ATTiny85 if you really want to optimize things. https://learn.adafruit.com/fft-fun-with-fourier-transforms/spectrum-analyzer