This is based off of a Ruhmkorff or induction coil design. It is a way to make alternating current (probably a square wave). I cannot guarantee that this will work, but it's based off of an induction coil design so it should work.
Step 1: Core
Use a steel bar for the core of your coil. This will be what your primary coil will be wrapped around if you decide I make an induction coil. If not, you will wrap wire around it anyway for an electromagnet.
Step 2: Wire
At this point, you will need to wrap several turns of heavier gauge wire around the steel bar (it must be able to magnetize well- so experiment with this). If you are making an induction coil, you would,at this point, wrap the secondary coil on the outside of the primary coil with thin wire for high voltage output.
Step 3: What Else
You could instead use this design and skip the secondary coil. You could use the alternating current for a general AC power source. You could put it on a Tesla coil. By the way: this requires a fairly large battery or a DC power supply most likely.
Step 4: The Mechanism
The mechanism works this way: a piece of magnetic metal (iron or steel) is attracted to the magnetic field the electromagnet produces on the steel/iron core of the coil. It pulls a small arm connected in the circuit, thus turning off the power. It then somehow has to return to the circuit (rubber bands or using gravity to pull it down by having the mechanism upside-down) which will turn the circuit back on, magnetizing the core and switching the circuit off, and so on and so forth. This is why a square wave is probably produced. In summary, the circuit activates the electromagnet and turns itself off. Once the magnetic field is gone, it switches back on.