There are two common ways to write a melody. The first is to create a chord progression, loop it and then start singing (improvising) over the chords recording what you sing. Different musicians have different ways, but singing, instead of plucking at the piano is often considered better because singing is a much closer representation of you and your heart. In fact in most improvisation books, players are taught to practice playing what they sing because of this fact. And that’s why they say, “man that guy was sure singing”. One downside to singing over a pre-made chord progression is that some musicians find that the chords restrict there creativity and their flow and so they prefer to use the second method which is to sing/improvise a melody first and then create (or have someone create) the chord progression. Creating progressions is a whole new art form, so for now to build very basic chords off your melody, try this out. Just about any note you sing, can be backed with a I chord, a IV chord, or a V chord. Once you like a song, play it for a pianist and have him/her help you create more practical chords. Neither of the two methods is “better”; it just depends on what you prefer as a musician. I use both. The key is prayer and practice. Sing anytime you can, wherever is practical.
The second step which is especially useful when you need to generate ideas or are creatively stumped (i.e. the singing technique just ain’t workin’ today) is something I learned in my music composition classes. This method can also be used to teach you the very basics of music composition. Take a very simple melody (I chose ‘eye on the sparrow’), write it out and then create two or three variations of it. There’s an infinite amount of tricks you can utilize to turn an existing piece of music into a totally new piece. For example, take a few of the notes and sing it in different ways or turn it into the hook of a new song. Anything goes, so long as it sounds good.
Finally, there’s a good book out there that really helps in the entire songwriting process. Its called 6 steps to songwriting success by Jason Blume. It will give you hundreds of ideas on the process, including a long and useful section on creating melodies.