The picture above shows an iron core nail wrapped in wire. When the ends of the wire are put onto opposite sides of a D cell battery, the nail becomes magnetic! This is an example of an electromagnet. Here’s a quote from http://www.electronicsteacher.com/succeed-in-physical-science/magnetism/electromagnetism.php that explains how electromagnets work.
“When electricity passed through a wire, a magnetic field is created around the wire. Looping the wire increases the magnetic field. Adding an iron core greatly increases the effect and creates an electromagnet. You can create an electromagnet without and iron core. That is usually called a solenoid.”
Basically what the quote is saying is the wire creates a magnetic field around the iron core nail, causing the nail to become magnetic. Did you see that the quote mentions a solenoid? The valve we used in our water drop photography was called a solenoid valve because it has an electromagnet inside of it.
Inside a relay there is a coil wrapped around an iron core and a switch. When power is given to the coil, the iron core becomes magnetic and the switch snaps shut. The switch closes because it is drawn to the electromagnet. When the switch is closed, the circuit is complete and electricity can flow. When power stops coming through the coil, the iron core is no longer magnetic and the switch opens, making it impossible for electricity to flow through the circuit.
If you want to try the experiment my dad and I did, all you need is an iron core nail, a wire, a D cell battery, and something metal that will stick to the electromagnet. Good luck if you decide to give it a try!