A solar cell is a heat engine, but textbook treatments are not wholly satisfactory from a thermodynamic standpoint, since they present solar cells as directly converting the energy of light into electricity, and the current in the circuit as maintained by an electrostatic potential. We propose a thermodynamic cycle in which the gas of electrons in the p phase serves as the working substance. The interface between the p and n phases acts as a self-oscillating piston that modulates the absorption of heat from the photons so that it may perform a net positive work during a complete cycle of its motion, in accordance with the laws of thermodynamics. We draw a simple hydrodynamical analogy between this model and the "putt-putt" engine of toy boats, in which the interface between the water's liquid and gas phases serves as the piston. We point out some testable consequences of this model.