Take a piece of string or wire and clamp it between a couple of points. Pull it somewhat tight. Now, put some energy into it, by hitting it or plucking it, or blowing on it. It will naturally vibrate at a basic frequency determined by the length, tension, and diameter. (that third factor is technically mass per-unit-length, but if the wires are the same material it comes down to diameter) Shorter = higher frequency, tighter = higher frequency, and smaller diameter = higher frequency. Then you make a way to clamp the wire at various points so you can change the length on the fly, and now each wire can make a series of frequencies depending on where it is clamped. Get a few more pieces of wire, of different diameters, and tension them next to each other and you can make an arbitrarily wide range of frequencies. That's it!
Considering string instrument construction, there's a little terminology to start with. The two fixed ends of the wire are the
nut (at the top) and the
bridge (at the bottom). Strings are usually anchored at fixed points below the bridge, and wound around adjustable posts above the nut so that the tension on each string can be adjusted for tuning. The in-between clamping points are commonly little metal bars called
frets, and the strings are pinched just above each fret. The open frequency of a string is defined by the nut-bridge length, string diameter, and tension, and the subdivision of each string's frequency is determined by the spacing and location of the frets.
Now for the relationship between frequencies, notes, and fret locations. Modern western music is dominated by a tuning system of 12 evenly-spaced notes per octave, based on a reference frequency of 440 Hz. Octaves are defined as a doubling of freqency, so an A note in the 4th octave (A4 = 440 Hz) is twice the frequency as an A in the 3rd octave (A3 = 220 Hz) which is twice the frequency of A in the 2nd octave (A2 = 110 Hz). The spacing between each individual note fits into the logarithmic pattern, so that the difference between any two notes is a factor of 2
(1/12) Hz. - the frequency doubles every 12 notes. The first note in each octave is C, for whatever reason, and the twelve notes are:
C, C#, D, D#, E, F, F#, G, G#, A, A#, B
This is referred to as the
chromatic scale. The # symbol means "sharp", but all the sharp notes are exactly the same frequency as the next regular note's "flat." Thus D-sharp is the same note as E-flat, except for the two notes that don't have a sharp: B and E. This convention makes little sense to me, but it's just the tip of that iceberg. Each note corresponds to a key on a standard piano keyboard. Here's one octave of keys, with a B and C on either end of the next octaves shown for reference.
Each note also corresponds to one fret on a guitar, so if you have a string tuned to a D, each fret position will play D#, E, F, F#, G, etc. down the fretboard. Say that the nut-bridge distance is 26 inches, and that D is D2. If you put a fret at 13 inches from the bridge, it will play D3, the same note an octave higher, because it is 1/2 the length. If you put another fret at six and a half inches, it will now play D5, two octaves higher than the open string, because it's now 1/4 the length. Few stringed instruments actually have a full two-octave range, but many are close.
Another option is a
diatonic scale, where you have only seven notes per octave. This is mostly on some old timey instruments like mountain dulcimers, accordions, and harmonicas. They are eight of the same exact notes as a chromatic scale, just missing some to leave just what is called a major scale. That is the familiar do, re, mi, fa, sol, la, ti, (do) thing. If the string is tuned to a C, the notes are the same as just the white keys on a piano, so you can't play any of the sharps. That works ok for many simple tunes, and traditionalists like it.
The physical distance between fret positions is related in the same way the notes are, by a factor of 2
(1/12) which I'll refer to as
a to simplify the upcoming formula. Given the total nut-bridge length as L, the distance to a given n-th chromatic fret is: L - (L /
an).