Using photosynthesis, which consists of a series of chemical reactions that require carbon dioxide and water, and store chemical energy in the form of sugar. Light energy from light drives the reactions. Oxygen is released into the atmosphere as a byproduct of photosynthesis.
This is the equation for photosynthesis: 6 CO2 + 6 H2O → 6(CH2O) + 6 O2