To obtain the maximum amount of electricity from a solar panel, it ideally needs to be mounted such that it faces directly towards the sun – perpendicular to the angle of incoming sunlight.
This angle depends on whereabouts on the globe the panel is situated. The further away from the equator, the steeper the angle will need to be to keep the panel facing directly towards the sun (see diagram below). The closer to the equator the panel is, the more flat it must be mounted to directly face the sun.

If the panel is situated exactly on the equator, it should be mounted completely flat to achieve maximum output power.
Solar Tracking Systems
The sun moves through the sky from sunrise to sunset each day. For maximum output, solar panels should face east in the morning to align with the rising sun, and then track the sun’s position as it moves through the sky from east to west.
Solar tracking systems are fairly common, but the improvement in efficiency is variable and dependent on the ambient temperature of the location where the solar panel is situated. For example, in a cold city like Berlin, Germany, an efficiency improvement of 39% can be achieved with a solar tracking system, whereas an efficiency improvement of only 8% is achieved in a hot city like Aswan, Egypt.
Also, the tracking system itself requires electricity to power it, thus decreasing the efficiency gains by about 5-10%; Meaning, solar tracking is not viable in hot locations, as the tracker uses more electricity than is gained.
Panel Mounting Direction
In the Northern hemisphere, solar panels should never be mounted on a north-facing roof. This is because from sunrise to sunset, the sun remains on the southern side of the sky so a north facing roof will remain in shade all day.
The opposite is the case in the Southern hemisphere – solar panels should never be mounted on a south-facing roof, since the sun is always in the northern side of the sky.

If you have a roof with east- and west- facing elevations, it is still beneficial to install solar panels, since the east-facing panels will be facing the sun in the morning, and the west-facing panels will be facing the sun in the evening.
Although this configuration is not quite as efficient as panels mounted on a south-facing roof. Studies have shown that 6 east facing + 6 west facing solar panels generate about 80% of the power of 12 panels all mounted on a south-facing roof.
Solar Generation at Night?
Solar panels can generate at night time, powered by sunlight reflected from a full moon. However, the amount of photons reaching the panel is greatly reduced, and studies have shown that the output of the panel is only 1/345th of its normal rated output.
So, for example, a 3450W solar array would generate only 10W. This is below the switch-on level for solar inverters, and so no AC mains electricity would be generated. However, if the DC output of the solar array was connected directly to a DC LED lighting system, it could feasibly power a few small LED lights.