Arduino Keytar

Created by: Mario Scala

Description: Using the idea of a "cigar box guitar", I took the body of one of these "guitars", inserted the Arduino brain into it and programmed it to produce certain notes based on where the strings were touching the frets, making an Arduino-ized version of a keytar. I also included a small knob on the keytar which acts as a "whammy-bar" for the guitar, bending the notes depending on how much it's turned.

Extended Description: The Arduino keytar code may look complicated but at least 60% of it is just a repeating line. Let's start at the top.

We declare our variables. I decided to use "buttonPin" because it's the variable name I used when I was learning how to use push-buttons, and that's essentially what the strings and frets serve as. A push-button, when pressed down, simply completes the circuit. Pressing the string down on the fret completes that circuit. So we assign the names of the strings and the potentiometer (which is the whammy-knob) and what pins they attach to. The strings are attached to wires that feed into the breadboard. They're connected to 2200 ohm resistors and in that same row as the resistor, connected via another wire to the pin.

Now let's look at the loop code, the part that assigns notes to specific values. We declare that the buttonState, buttoState2, or buttonState3 reads the value of the pin once it completes the circuit (or touches the fret).

The string of resistors runs from a positive lead in the breadboard and down the neck of the guitar. The resistors are soldered together to ensure a connection is present. A third wire is soldered from the interlocking resistors to the fret. This is where our values will come from. The resistance going through the resistor can now be detected in the fret, giving us something to measure for our value. So, when we touch the string to the fret, the Arduino can detect the value that runs through the resistors.

In short, the value of ohms running through the resistors changes as you touch frets that are further down the neck. We tell the Arduino to measure this value, giving us the numbers in our code, like "if(buttonState>=900 && buttonState<=910" for example. The "delayMicroseconds" command will tell the Arduino how long to wait before producing the tone again. Making it delay in microseconds will make the tone sound constant as if there were no breaks in it. If we press down on a fret and the value is anywhere between these numbers, we go on with the code and play the note that we assigned to it. If no frets are pressed down (or specifically, if no value requirements are met) then, based on the code, no sound will be produced.

The value of a given resistor is pretty much constant across the fret, meaning that it will be close to the same for all strings. This means that over 60% of this code is simply repeating and changing the variable names and a couple of other numbers to create a wide range of notes across all strings and frets.

Problems: I didn't have many problems but I did have a couple that were a pain trying to deal with. I would say that between 70-80% were a result from building the actual keytar. The most frustrating part of building the keytar was soldering a wire from the resistors running down the neck of the keytar to the frets. At first it seemed that the music wire was too thick to soleder a wire to so I tried wrapping magnetic wire around it and then soldering that wire to the resistors. Well, it turned out that I didn't burn the coating off the magnetic wire enough so it wasn't conductive at all. I then removed all of the wire and decided to just try to solder regular wire to the music wire again. This time it actually worked and ended up turning out great.

Another major problem I had was the third string playing the same notes as the second string. After an hour of trying to figure out if it was the code or the wiring I found out that the third string was making contact with the second string at the head of the guitar, causing it play whatever the second string did.

The only other problem I ever had was when measuring the current in the resistors when I pressed a string down on the fret. As I put more and more frets on, any fret from around #7-14 started having inconsistent values. To fix this, I decided to assign any fret from that number on to produce the same note, but instead it would be a note with a high frequency that could be manipulated very easily from the "whammy-knob".

Things i would like to change: If I had more time, I would like to make an easier way to hold to strings in place. The bolts and knobs that were in the head of the guitar ended up working but were finicky when it came to holding strings in place. If I could redo it, I would want to put in newer bolts and maybe change the way they hold the strings in to make it less of a hassle.

Another thing I would change is the speaker. The speaker isn't as loud as I would have liked and if I had more time I would want to put in a higher quality speaker.

One of the most important things I would like to add is a battery so that you don't have to hook up the guitar to a computer to power it, along with a strap bolted onto the guitar so you could walk around and play without any limitations.