A solenoid is a coil of wire tied across a piston that is made of iron, in the form of a corkscrew.
According to the laws of electromagnetism, when an electric current passes via the wire a magnetic field is generated.
The advantage of electromagnets over permanent magnetic material is that they can be turned on and off by adding or removing the electrical field, making them effective as controls and switches, and enabling them to be automated.
The magnetic field of an activated solenoid has both north and south poles that attract or repel sensitive material to the magnets.
Hence, a solenoid is used as a power switch.
It can be used to electrically control a valve as per our requirement.
The direction of the magnetic field is given using the right-hand thumb rule.
From the law of the Ampere, the magnetic field created by a solenoid can be described as,