A camshaft is an important component
of a four-stroke
engine. The valves
at the top of each cylinder
of an engine
are responsible for air and fuel coming in and and exhaust gases coming out. It is important that these valves open and close at the right time relative to the firing
of the spark plugs
So, how does the camshaft do this? The camshaft is connected (usually by a chain) to the flywheel of the car that the pistons drive via the crankshaft. This turns the camshaft. The camshaft is generally round, but has little knobs on it. At the places where the knobs are (usually two for each cylinder), sit rockers. When the knob touches rocker, it pushes it up. This in turn, pushes the valves open, letting in air/fuel or letting out exhaust.
Some motors have two camshafts for additional fine control of opening and closing values. This is where the abbreviation DOHC (which stands for "double overhead cam") comes from.
You have to make sure that the "knobs" are in the right place relative to the firing of the spark plugs, otherwise the motor will not produce anywhere near optimal power. This is part of what is done at a tune up.