He connected the wire of the north pole to the negative pole of the battery and the wire of the south pole to the positive pole. The basic law of magnetism told him what would happen: the north end of the electromagnet would repel the north end of the horseshoe-shaped magnet and would attract the south pole. The same happened on the other side of the nail, with the result that the nail turned. 