Play or sing the scale of the key — try playing it going up and then play it going down. If the composition starts with an up beat or "anacrusis" or "pick-up"the last bar of the melody needs to compensate. If you are just starting out I suggest you compose using C major and A minor.
Try repeating 1 or 2 of the notes and change the rhythm of what you are playing until you find an idea you are happy with this initial idea that you come up with is called a motif. The rhytm has to be same not neccessarily the notes. Bar 3 is like bar 1, but is one degree of the scale lower.
Have a pleasant line. Effective Composing You might think that writing a melody without being able to hear it is impossible - but did you know that Beethoven wrote most of his great music when he was completely deaf?!
Writing a melody over a chord progression Most contemporary popular music is written in this way. Every piece of music has two vital elements - rhythm and melody.