The most common type of diode is the semiconductor diode, which uses a p-n junction to control the flow of current. A p-n junction is created when two pieces of semiconductor material are joined together.
The semiconductor material has a p-type layer, which is made of positively charged particles, and an n-type layer, which contains negatively charged particles. When the two materials are joined together, the positively charged particles of the p-type layer are drawn to the negatively charged particles of the n-type layer, forming a barrier.
This barrier will allow current to flow in one direction, but will block it from flowing in the opposite direction.