I really enjoy building mechanical movements, and I am terrible at it. It is really difficult to build things that move without relying on expensive pre-built mechanisms. Thus I am always looking for cheap ways to design and build cogs, gears, and sprockets.
For gears it is tough to beat the online wooden gear generator at woodgears.ca. It lets you specify size and number of gears, and also lets you see how they mesh and tweak a bunch of variables. I usually print these to pdf and then import them as vector to illustrator. With this site you can build any number of compatible gears. They have rather large teeth because they are meant to be cut out of wood with a bandsaw, but they will work very well for low-precision work. There is also an inkscape plugin that generates gears as described here by MAKE.
One note on importing all of these files into illustrator. Illustrator has strange import prefs, and if you import a dxf that is in mm, and your preferences are in inches, centimeters, or anything else, then it will scale your drawing on import. Be careful. This is an easy way to mess up at the very first step.
Timing belt cogs are another deal entirely. There isn’t an online generator. There are a few python scripts that purport to build cogs, but they never seem to work right. One other way to do it is with blender and a plugin, but then you end up doing more 3d modeling than cutting.
To build one in illustrator you will need to know the belt you plan on using and the number of teeth you want the cog to have. You will also want to go to sdp-si and download an example any cog that uses your belt pitch. Set your units to mm in illustrator>preferences>units. Grab the dxf of that cog and open it up in illustrator.
More than likely you will see something similar to the image below. It has two example teeth showing the tooth spacing, but the entire cog isn’t drawn out as a time saving measure.
here’s how to duplicate out the rest of the teeth and more.