Electrical energy is produced by converting solar energy using photovoltaic cells. Photovoltaic cells directly convert sunlight into electricity through the photovoltaic effect. When sunlight hits the cells, it excites electrons, generating a flow of electricity.