This animation shows the working of a simple electric bell.
When the switch S is closed current flows round the circuit, through the electromagnet — along the spring — through the contacts — through the adjusting screw and back to the battery again. The electromagnet therefore attracts the soft iron armature and the striker hits the gong once. As soon as the armature is attracted the contacts are opened and so the current stops flowing. This switches off the electromagnet, the spring pulls the armature away — the contacts meet again and so the current starts flowing again. This is repeated over and over again and so the bell rings.