When the chord changes, see if your melody note fits the new chord. If not, find a nearby note that does. You never have to move by more than one step to fit into the new chord.
For a little extra interest, you can add a few notes that don't belong to the current chord. (The fancy technical name for these notes is non-chord tones.)
- You can move from one chord note up or down to another chord note, passing through one or two inbetween notes that don't belong to the chord. (The notes inbetween are called passing tones.)
- You can start on a chord note, take one step down to the next note, and then back up to the first note. (That lower note, which doesn't belong to the chord, is called a neighbor tone.)
- You can also go one step up to the next note, and then come back down. (Also a neighbor tone, the upper neighbor.)
- You can start the measure with an accented note that's not in the chord -- a pointedly dissonant note. But you quickly resolve the dissonance by moving down one step to a note that belongs to the chord. (If you want to get really fancy, you can also move up one step to resolve the dissonance.)
- Pick a series of notes that fit with the chord progression.
- Here and there, change a few of the notes to non-chord tones, using any combination you like of the four kinds of non-chord tones listed above.