Pattern for vertical motion using technic lego
You can accomplish this using gear racks (3743):



You just have to create some type of channel that allows the rack to slide vertically, and then set up a gear to mesh with the rack. You can do this however you like, but here's a quick example that I built to show you what I mean: