A crowd of hushed spectators packed into the small red factory house at the Speedwell Ironworks in Morristown, New Jersey, unsure of what to expect next. Samuel Morse, along with his colleagues Leonard Gale and Alfred Vail, had packed over two miles of wire into the building, attempting to demonstrate to the public that his strange new invention could be used to transmit messages over long distances. Finally, the inventors manipulated a primitive transmitter, and a receiver scratched Morse’s simple message—”A patient waiter is no loser”—via a code of lines and curves. On this day in 1838, the small group of onlookers saw something special: the first-ever public demonstration of the telegraph.

Related Content The Roots of Computer Code Lie in Telegraph Code

Of course, as with all technological breakthroughs, the development of the telegraph had started years earlier, says curator Harold Wallace of the American History Museum. But unlike many other inventions, the telegraph was the result of an unusual mix of personal circumstances, artistic influences and pure happenstance. For the first four decades of his life, Morse was first and foremost an artist. “He was a painter of modest renown,” says Wallace. “Not top tier, perhaps, but his name was known.”

Morse was first provoked to think about communications technology because of a tragedy: in 1825, while painting the portrait of the Marquis de Lafayette in Washington, D.C., he received a letter indicating his wife was sick. By the time he reached his home in New Haven, Connecticut, she had already been buried. Stricken by grief, he vowed to develop a faster way to send messages in such crucial circumstances.

For several more years, Morse struggled in vain to succeed in the art world, but in 1832, serendipity intervened. On a transatlantic voyage, returning home from study in Europe, he met Charles Thomas Jackson, a Boston physician and scientist, who showed him a rudimentary electromagnet he had devised. Morse became convinced that he could somehow send a message along a wire by opening and closing an electrical circuit, which could be recorded by an electromagnet on a piece of paper via a written code.

Back in the U.S., he moved forward with his idea, meeting with Joseph Henry, another scientist working in electromagnetism—and the man who would later become the first secretary of the Smithsonian Institution, in 1846. “He met with Henry, who explained how the electromagnets worked and showed his experimental ones,” says Wallace. “And if you look at the electromagnets—the ones Morse uses, and the experimental ones from Henry—it’s obvious they’re the same design. He’s definitely riffing off of Henry, as far as the electromagnet, which is one of the most important pieces of the apparatus.”

Morse returned to his New York apartment and, in 1837, he crafted a primitive telegraph receiver—now part of the Smithsonian’s collections and currently on display at the American Art Museum—that was able to register and record the fluctuations in an electrical circuit. “The most interesting thing about the prototype is that he took an artist’s canvas stretcher and made it into a telegraph receiver,” Wallace says. “So right there, you can see the shift from painter to telegrapher, all in one piece.”

With a means of recording electromagnetic signals theoretically in place, Morse worked with Gale, Vail and others over the next several years to improve the system and make it practical for use over far distances, incorporating Vail’s transmitter key and a code of dots and dashes, which of course would become known as Morse Code. Despite these improvements, the group had some difficulty convincing others that telegraphy was a worthy investment. “It was not difficult to convince people at the time that it was potentially useful,” Wallace says. “What really was the hard sell that Morse and others had to make was whether it could be practical. Could you create wires miles and miles long and send a signal through them?”

To raise capital for long-distance lines, he turned to the U.S. government, and after a small-scale demonstration with wires strung between different committee rooms within the Capitol, he was awarded $30,000 to build a 38-mile line from Baltimore to Washington, D.C. On May 1, 1844, Morse’s communication device was finally met with wide scale public enthusiasm, as the Whig Party’s presidential nomination was telegraphed from Baltimore to D.C. far faster than a courier could have traveled.

Later that month, the line was officially opened for public use—with a message quite a bit more well-known than that of the the earlier Speedwell Ironworks demonstration. This, too was recorded on a strip of paper, which now resides in the American History Museum’s collections. Short yet meaningful, the bible quotation set the stage for the approaching age of electronic communication: “What Hath God Wrought.”