Photosynthesis is the process by which plants, algae, and some bacteria use sunlight, water and carbon dioxide to produce oxygen and energy in the form of glucose. It occurs in two stages - the light-dependent reactions where light energy is captured and used to produce ATP and NADPH, and the light-independent Calvin cycle where ATP and NADPH fuel the building of glucose molecules from carbon dioxide. Chlorophyll and other pigments absorb sunlight which is then used to split water, producing oxygen, protons and electrons. The electrons are passed through an electron transport chain which generates a proton gradient used for ATP synthesis.