A diode is a semiconductor device that allows current to flow in only one direction. It is like a one-way valve.