Solar energy is one of the most widely used renewable sources of energy. Nowadays, much research is conducted in the area of implementing solar energy based electrical sources into electrical power systems. The solar energy based electrical sources are either connected to electrical grids or operated in a standalone mode of operation. This paper proposes a smart control system based on PWM technique to address both situations. This smart controller controls the solar cell operation while connected to the grid. If the system is intentionally islanded, the control system can automatically detect the islanding and changes the control system objectives based on the current mode of operation.