One of the most important things when playing guitar is making sure the instrument is in tune. Even the best guitarists won’t sound any good with an out-of-tune guitar. Manual tuning with a standard tuner has always been common, but the automatic tuner makes things easier and more fun! This Arduino based project will tune your guitar for you.


The image above shows an overview of the automatic guitar tuner.

button to select the strings to tune

Six LED display to indicate which string is selected

A clamp attached to the motor is used to turn the tuning pegs until the strings are aligned.

Inputs and outputs are controlled by the four circuits described above: the digital input circuit for the buttons, the analog audio input circuit for the guitar, the digital output circuit for the LED display, and the motor drive circuit for the tuning pegs. These four circuits interact with the Arduino Due, which is running an algorithm developed using Simulink.

audio input circuit

The guitar is connected to the tuner via a standard guitar cable. The end of a guitar cable has two connections called tip and sleeve. One end of the cable will go to the input jack, which has leads for the tip and sleeve. I soldered wires to these leads to connect the tip and sleeve to the audio input circuit.

I recommend using the TL972 op amp in this circuit. It is a very low noise rail-to-rail amplifier that can operate at very low supply voltages.

Electric tuning peg clip

No DC motors were used in this project. I need a geared motor with low speed and high torque. The motor I am using is 6 RPM and max torque is 613 oz-in. It has a voltage range of 3-12 V, so I use a 9 V battery for power.

On the motor’s shaft, I assembled a simple clamping mechanism using a clamp hub, four screws, and some tape.


I use Simulink and its support package for Arduino to develop the algorithm for the tuner. Simulink is a block diagram environment for developing algorithms and modeling dynamic systems. The support package allows me to use the Simulink module to read and write to the pins on the Arduino. Using the software’s external mode feature, I can simulate an algorithm on the Arduino, automatically generate code and adjust parameters while the simulation is running, without having to recompile any code. I can then deploy the algorithm to hardware for standalone execution. The model I created looks like this:

External mode allows the use of scope modules to monitor parts of an algorithm running on hardware. This is especially useful for the digital input of the monitor buttons and the analog input of the guitar. From the button scope we can see that the input changes from 0 to 1 when the button is pressed.

I want this change from 0 to 1 to trigger a change in the selected string. This is called a rising flip-flop. I created a Stateflow chart called “Select String” that has six states, one for each string, and changes from one state to the next based on this rising trigger input. Here is a more detailed introduction to Stateflow charts:

After entering each state, the LED pin of the corresponding light string is set high. On exiting each state, this pin is set low. I chose the lowest low E of the six strings as my default. When I turn on the tuner for the first time, it starts up in this default state.

There are seven outputs on the Stateflow chart: one for the LEDs for each of the six strings, and one called “periodRange”, which I’ll discuss later. The six LED outputs go directly to the Arduino digital output module to turn the corresponding LED on or off.

Now let’s look at the audio processing part of the model. The guitar signal comes in through the analog input module. For a sample rate of 5 kHz, I set the block sample time to 0.0002 seconds. When I play the guitar and open the audio range block, I am able to see a waveform like the image below:

The oscilloscope block helped me adjust the potentiometer in the audio circuit to change the gain of the input. The gain should be set as high as possible without the peak value of the waveform reaching the maximum value of 1023. This will allow the most accurate reading of the signal.

When not playing the guitar, the input signal should be a straight line between 500 and 700. In my case it was around 550. Knowing this value is important because the tuner should only handle audio when there is a note playing. I chose a value of 575, just above this flat line, as my threshold. Audio will only be processed when the signal is above this threshold. Since Simulink allows me to tune parameters while the simulation is running, I can easily set thresholds.

When a single note is played on the guitar, the resulting waveform is periodic. The period of the waveform corresponds to a certain pitch. The tuning algorithm estimates the pitch of the string by determining the period of the waveform. I wrote a MATLAB function that performs this pitch estimation and included it in my Simulink model using a MATLAB function block. To determine whether strings are in tune, the MATLAB function requires an input indicating the tonal range of each string. This is the output “periodRange” from the Stateflow chart. This function determines whether the pitch of the string is too high, too low, or into tune based on the period range, and generates an output for the motor accordingly.

The output of the MATLAB function is the three pins that control the motor. These outputs go directly to the Arduino digital output module.

Once I’ve made sure my algorithm is all right, I can deploy it to hardware so it can run on its own without being connected to a PC and independent of Simulink.

Leave a Reply

Your email address will not be published.