Sorry, this article is incomplete. We'll have this finished up soon. In the meantime, check out some other articles on Cars Simplified!
Valves are timed so that they open to let air in and exhaust fumes out, and so that they open and close fast enough to not get hit by the piston. The timing is controlled by the camshaft, which also controls how far they open.