Solar cells work by absorbing photons from sunlight using semiconducting materials like silicon, which excites electrons from their orbitals. The electrons either dissipate as heat or travel through the cell to electrodes, generating a current that is captured as electricity. Silicon is typically used in two layers doped differently with boron and phosphorus to drive electrons based on their differing electric charges. An array of solar cells converts sunlight into usable DC electricity, which an inverter can then convert to AC power.