You can write a song, using chords from various keys,and you can get them to sound good, but generally there are a few simple rules to follow.
In any given key, certain chords are much better at following the previous chord than others.
Here is a chord leading reference guide.
The I chord can lead to any chord
The ii chord leads to to IV,V,vii
The iii chord leads to the ii,IV,vi
The IV chord leads to the I,iii,V,vii
The V chord leads to the I
The vi chord leads to the ii,IV,V,I
The vii chord leads to the I,iii
As a guide
I ii iii IV V vi vii
C D E F G A B
So C F G Are Major chords
The D E and A are minor chords
and B is diminished( not often used)
All chords can be altered to "colour chords" ie Cadd9, Am7 etc.
Hope this helps, you get started at having a go at creating your own music.
K.Amess




