By the age of 21, Samuel Morse showed an interest in electrical experimentation. A shipboard conversation in 1832 planted the seed for a method of telegraphy, and by 1835 the basic physical elements of a relay system were in place. A patent was issued in 1840, and the U.S. Congress gave him a grant for $30,000 to construct a line between Washington and Baltimore. The first message on this line was sent on May 24th, 1844.
The "Morse Code" was invented by Morse, and his assistant Alfred Vail about 1840. The original code was simplified in 1851, and is called the 'Continental', or 'International' Morse code.