Play an instrument to a chord progression that sounds pleasing to you. This can be a simple set of chords, such as C, G, D, or it can incorporate more complex set of chords, such as F, B flat, C, B flat, F. You can write a melody within any chord progression, but it is good to start with a basic progression when you are first beginning to write melodies.
Add rhythm to notes within each chord progression. As you play different notes to rhythm, use pencil and paper to write down the set of notes and their rhythms that you enjoy and can add lyrics to if you desire.
Continue to play and work with the melody you are beginning to write with your chord progression. Once you have three or four sets of continuous melody stanzas, you can begin to repeat all or part of your melody to create a full song. You can even add a chorus that stands out from the rest of the song and is repeated two or three times. Add lyrics to the melody if you desire.