Explaining Carnot's Engine...
The first clear explanation of how an engine could use heat energy to perform mechanical work cyclically was given by Sadi Carnot in 1820.
He took as his model a gas contained in a cylinder with a moveable piston. It underwent a four-step cycle: beginning at a high temperature, heat is fed in from a fire, the gas is allowed to expand so the temperature does not increase. In the second step, the gas is allowed to expand, still pushing the piston, but no heat flows in or out. The gas cools. Thirdly, the cool gas is compressed, keeping its temperature constant, so heat flows out. Finally, the gas is compressed further, this time with no heat flow, so its temperature goes up to the initial value, and the cycle can repeat.
The expansion parts of the cycle are at higher pressures than the contraction parts, so the engine does net work. Other heat engines have different cycles in the pressure vs volume graph, but the basic idea is the same.
Many details are available at my lecture here.
Applet code by Lawrence Hook.