A diode works based on the principle of a p-n junction , where the flow of current is determined by the biasing voltage applied to the diode.