ATP is the cell's currency of energy. To make ATP takes energy, though. In order to do this, energy is used either from sunlight in photosynthesis or from chemical reactions in respiration to move electrons across a membrane via an electron transport chain, here illustrated by Medieval Guy. When you move negatively charged electrons across the membrane, though, you create an imbalance of charges. In order to bring charges back into balance, positively charged protons flow from one side of the membrane through the other, and the movement of these is harnessed by ATP synthase to produce more ATP. BTW, I was at UCLA in 1997 when Paul Boyer was awarded the Nobel for his role in the elucidation of the ATPase mechanism. I was also there in 1995 when UCLA won the NCAA basketball championship. On one of these occasions there was a reception hosted by the Department of Chemistry and Biochemistry. On the other occasion there was mini riot in Westwood Village of drunken college students. Can you guess which was which?