MIT Physics Demo -- Telegraph Transmitter
A solenoid enclosed in another solenoid is connected to a 12 volt battery. Also contained in the circuit is an iron contact switch connected to a spring arm, with a gap on one side of it. When the circuit is closed, the inner solenoid attracts the iron switch across the small gap. This breaks the circuit, making the switch move back to its original position, which closes the circuit again. Thus, the switch moves back and forth quickly, causing oscillations of high voltage in the outer solenoid. This high voltage causes sparks to jump the large gap between the ends of the outer solenoid.
These sparks cause electromagnetic radiation, which is how telegraphs were originally transmitted wirelessly. Morse code can be transmitted by opening and closing the power source.
This specific transmitter was made by the Marconi company, and is very much like the telegraph machine that would have been used on the Titanic. Read more about spark gap transmitters here.