There are more than 311,000 traffic signals in the United States, and most of those signals are simple traffic lights. In fact, there’s a good chance that you drove through a few green lights on your way to work, and you’ll almost certainly spend a few minutes waiting on a red light before the week’s over.

image Rogers

How did we decide on red and green lights, and why don’t we use some other system? To get the answers, let’s look at the surprisingly interesting history of the traffic light.

Believe it or not, the first traffic lights predate the widespread use of electricity.

In the early 1800s, police directed horse-drawn carriages and other vehicular traffic in major cities. That system worked fairly well, but authorities wanted clearer signals to prevent dangerous misunderstandings and to allow for a smoother flow.

In 1865, engineer John Peake Knight, a railway manager in London, approached the Commissioner of the city’s Metropolitan Police with an idea. Knight noted that trains use a semaphore system; a signal with a raised or angled arm could tell conductors whether the path was clear. Drivers, he reasoned, could use the same type of system on public roads. The first light was installed in 1868.

The semaphore system worked well during the day, but it was largely useless at night. To this end, Knight came up with another novel suggestion: Use red and green lights, powered by gas. Individual police officers operated these first traffic signals by hand, blowing a whistle before changing between the lights and semaphores.

The system worked well enough at a single intersection, but in 1869, a gas leak caused an explosion, injuring the officer working the lights. The city of London discontinued the project.

In the United States, the idea of signal lights caught on.

Railroads began using lights to provide indications to engineers. Instead of using two lights, they used three: red, green, and white.

image Lee

The original design used green to signal “caution,” while the white signaled “all clear.” While the lights worked, in some cases, the results were disastrous. Train conductors couldn’t always see the white lights, and the tinted glass that gave the lights their colors could break, causing a red light to appear white.

Eventually, officials decided to get rid of the white light, changing “green” to mean “go.” They also added in a yellow light, which indicated “caution.” The new signals worked extremely well.

Still, the traffic lights were reserved for trains—not the traffic on public roads.

Change came quickly with the introduction of automobiles. In 1914, the city of Cleveland tried a system similar to the London semaphores, this time using electric lights instead of gas. The city placed the first light at the intersection of East 105th Street and Euclid Avenue, but once again, the lights were operated manually, and the signals relied on two colors (red and green). The light was very successful, and even though it wasn’t the first experiment with traffic lights, it is widely credited as having sparked the technology’s popularity.

image Roberts

In 1920, Detroit police officer William Potts introduced the three-color traffic signal, taking inspiration from the red, yellow, and green lights of the train signal. In 1922, Houston added the first automatic timers to traffic lights, which saved cities a tremendous amount of money; by one estimate, the city of New York saved $12.5 million by re-assigning most of its traffic cops.

Traffic lights spread quickly, in part because they’re much more effective (and therefore much safer) than traffic signs. A San Francisco traffic engineer found that 70 percent of drivers at the time ignored stop signs, while an Ann Arbor traffic engineer reported that 98 percent of drivers obeyed red lights.

So, why does red mean “stop,” and why does green mean “go?”

The first traffic lights needed to use colors that were clearly visible from a long distance and noticeably different from one another.

The red light was an easy choice. For centuries, humans have associated red with danger, so the color was an obvious choice for “stop.” Besides, red was already used as a traffic signal of sorts; through the 19th century, ships used red flags to declare that they were carrying explosive cargo.

image Suarez

Green gradually became synonymous with “go,” but that took a concerted effort from public safety officials. One engineer even wrote a description of the nursery school game “red light, green light” in a notable technical journal in an apparent effort to spread awareness of the new traffic signals.

Today, drivers depend on consistent, reliable traffic signals to navigate the roads.

However, three-light traffic signals aren’t perfectly uniform. The order of the lights can vary from country to country and even within the limits of a single city. Contrary to popular belief, the order of the lights isn’t specifically set to help colorblind drivers—colorblind people can see different hues, so they have no problem identifying the correct signals—but rather to help all drivers navigate the roads safely. In the United States, the red light is usually on top.

The next time you pass under a traffic light, keep this strange history in mind. While nobody likes waiting for a light to change, we’d all be waiting much longer if traffic lights didn’t exist in the first place.