Diminished sevenths create extra colour and direction to a chord progression and can also be used to modulate to a new key.
As a diatonic chord (i.e. a chord within a key) a diminished seventh only appears as vii7 in a minor key.
Therefore if we see/hear a diminished seventh we can work out what key it implies because it appears only once in each key (i.e. as vii7).
Diminished sevenths are used chromatically to emphasize a chord other than the tonic. In C major, I could emphasize a D minor chord (chord ii) by borrowing chord vii7 from D minor and creating the chord progression vii7-i in that key. In this situation you can say that the diminished seventh is vii7 OF ii (i.e. we have borrowed vii7 of D minor)
As a borrowed vii7, diminished sevenths nearly always resolve to their tonic, which is a semitone above the root.
In the example below the F# diminished seventh resolves to ii (G minor) and the B diminished seventh eventually resolves to C (with a 6/4 in between).
Mozart Piano Sonata in Bb K. 333, first movement
How to write diminished sevenths
- decide on the chord to which your diminished seventh will resolve
in this example an E major chord (V of A major) - write down the note below the root of this chord
in this example D – one note below E - add three thirds above the root of your diminished seventh
in this example, F#, A, C# - add accidentals that would apply to the MINOR key whose root is the chord to which the diminished seventh resolves
in this example the chord to which the diminished seventh resolves is an E chord, so you need accidentals that would apply to E minor (change the D to a D# and the C# to a C natural).
the root note of the diminished seventh must resolve up a semitone and the seventh should resolve down, as in the example (i.e. if a violin had the C natural it should follow it with a B)