The valve gear of a steam locomotive is responsible for admitting the pressurized steam into one end of the cylinder or the other with the right timing to cause the driving wheels to rotate continuously. More subtly, the valve gear does this in such a way that steam is only admitted during part of the stroke of the piston, the force during the reminder of the stroke coming from the expansion of the steam.
Changing the point in the stroke after which more steam is no longer admitted has an effect much like changing the gear ratio of an automobile transmission. There, low gear gives the greatest torque at low speed, while high gear makes best use of the fuel when the car is rolling along at speed. Similarly, in the locomotive, allowing steam to enter the piston during the entire stroke gives the greatest average torque at low speed, while an early "cutoff" makes best use of the fuel when the train is rolling along at speed.
The design of mechanisms to manage the steam admission (and the matching matter of its exhaust) was over the years a rich adventure of inventors. The valve gear that ultimately came into widest use was invented in 1844 by the Belgian engineer Egide Walschaerts. Not surprisingly, it is called the "Walschaerts valve gear" (or sometimes, inexplicably, the "Walschaert valve gear").
We see a lovely example here:
Photographer unknown:
Walschaerts valve gear on Pennsylvania Railroad E6s
on a Pennsylvania Railroad E6s locomotive (4-4-2, "Atlantic" type).
On the right, over the two leading truck wheels, we see to large cylindrical items., The lower is the steam cylinder itself, inside of which travels the piston; the upper contains a "spool" valve, which admits steam to, or exhausts steam from, one end of the cylinder or the other.
The various smaller links and levers are part of the Walschaerts valve gear, the fascinating details of whose operation I will spare you.
It is a wondrous thing.
Best regards,
Doug