Think of the automobile engine as an air pump. It converts the reciprocating motion (up and down) of a piston into rotational motion (this is where torque comes from) of a crank shaft. The strokes of a 4-stroke engine are: intake, compression, power and exhaust. On the intake stroke, the piston is brought down in its cylinder and the intake valve opens. Air is pushed in by atmospheric pressure and gets mixed with an appropriate amount of fuel. On the compression stroke, the intake valve closes and the piston moves upward. This squeezes the air/fuel mixture together in the space known as the combustion chamber. Compression thoroughly mixes the fuel and air for the most effective burn. The power stroke happens after the piston has reached its highest point of travel in the cylinder, which is known as top dead center. The spark plug ignites the air/fuel mix and the piston is forced downward by the expansion of burning gasses. During the exhaust stroke, the piston begins to move up and expel the burnt mixture through the exhaust valve opening. An easy way to remember these strokes is: Suck, Squeeze, Bang, Blow.
The intake and exhaust valves are operated by a camshaft which is precisely synchronized with the rotation of the crankshaft. As the camshaft turns, the egg-shaped lobes move the valve lifters up and down which translates into the opening and closing of each valve. In older engines the camshaft is also responsible for firing each spark plug at the right time. This is accomplished by means of a gear on the camshaft that meshes with a distributor shaft gear. Modern engines rely on an electronic signal from the camshaft position sensor that is sent to the engine control module. Through proper timing, also called spark advance, about 30,000 volts of electricity is delivered to each spark plug.