I got these gears from VexRobotics http://www.vexrobotics.com/276-2169.html with these http://www.vexrobotics.com/276-1957.html racks, and I've opened the holes up the gear to fit them into a stepper motor Stepper motor - NEMA-17 size - 200 steps/rev, 12V 350mA : ID 324 : $14.00 : Adafruit Industries, Unique & fun DIY electronics and kits. But the shaft is very smooth and they tend to slide off and not align properly. Any advice on how to align the Gear onto the shaft, and how to get it actually attached on there would be helpful.
The motors have a D type shaft.
It has a flat side to an otherwise round shaft.
The flat side allows for a screw to be screwed to the shaft, fixing whatever you want to fix to it with low chance of slipping afterwards.
If you fit the plastic gear wheels by drilling a round hole instead of the square ones they come with, you now have to create some other way of fixing them.
Glueing or heating the shaft so that the gear may melt to it come to mind.
If the gears are not subjected to much torque, you can force a thin rod or piece of wire into the gear hub where the flat side of the "D" is located.
Find a pair proper grub-screw collars/pinions and sandwich the gear between them and
epoxy together? Find a metal gear designed for 5mm shaft?
Loctite is a very good sealant for this kind of application.