A diode is a semiconductor device that allows electrical current to flow in one direction while blocking it in the other.