Pioneering Women Women of Science

Margaret Hamilton | The Code That Got Us To The Moon

Margaret Hamilton is an American computer scientist and software engineer. She led the team who developed the software for the Apollo moon missions and for the Skylab space station in the 1960s and 70s. It was her code that helped get us to the moon… and back!

The Code that Got Apollo to the Moon

Margaret Hamilton and the code that got Apollo to the moon
Margaret Hamilton and the code that got Apollo to the moon

Hamilton is pictured above with the stacks of code written by her and her team at MIT for the Apollo space missions.

Hamilton was a self-taught programmer, working in the US in the 1960’s. Owing to the success of her previous work, Hamilton was the first programmer to be hired for the Apollo project. She became the Director of Software Engineering at the MIT Instrumentation lab. Her lab developed the on-board flight software for NASA’s Apollo space project, which took humankind to the moon.

Apollo 8 and the Programming Fail-safe

Margaret Hamilton was a very innovative programmer, which lead her to make software that was more robust and reliable than ever before. She saw the need to design software that could deal with unpredictable problems and errors.

One night, Hamilton’s daughter Lauren, was playing ‘astronaut’ in the flight simulator. The flight simulator crashed because Lauren had selected program P01 a pre-launch program, whilst in mid-flight.

Hamilton realised that if an astronaut made a mistake and entered the wrong command code during a mission, there could be disastrous consequences. She recommended a software design that would over-ride this kind of human error and keep the flight systems working – a sort of fail-safe. She was told it would never happen, as astronauts are too well trained.

The Apollo 8 Moon Orbit – It Happened

During the very next flight – the moon-orbiting flight of Apollo 8, it did happen. Astronaut Jim Lovell made a mistake and entered the wrong command code. Just as Hamilton’s daughter Lauren, had done in the flight simulator, Lovell had entered the pre-launch code P01 during flight.

Launching the P01 program erased all the navigation data and without that the Apollo computer wouldn’t be able to get the astronauts home.

Hamilton and her team at MIT spent nine hours trying to come up with a fix and eventually found a way for Houston to upload the navigational data needed to get Apollo 8 and its crew home safely.

For all future Apollo missions, Hamilton’s team were given the go ahead to write protective code in to the software to prevent any future problems resulting from this kind of human error.

Apollo 11 Moon Landing – Go Or No Go?

Lunar Module - The Eagle. Moon landing
Lunar Module – The Eagle

The Apollo moon landing was nearly aborted when the moon landing module – the Eagle began to send out a warning alarm during landing. The alarm code 1202 meant that the Eagle’s computer systems were overloaded.

During the landing the computer’s processing was crucial. The Eagle needed about 90% of its processing power to focus on the tasks required for landing. With only a 10% margin there wasn’t much room for error, but the 1202 alarm meant that vital processing power was going somewhere else.

Hamilton’s Code Saved The Mission

It was due to Hamilton’s priority display system that astronauts Buzz Aldrin and Neil Armstrong were aware there was a problem. As lead software designer for the Apollo flights, Hamilton had created a ‘priority display’ system. This meant that astronauts would be notified of any error or problem with the system.

Buzz Aldrin and Neil Armstrong relayed the warning code to mission control, at Houston, where they could interpret the code and make the call – whether to go or abort the moon landing mission. Houston were able to look up the error code due to Hamilton’s warning system and give the go signal to continue the mission.

The Fix

During the time Armstrong and Aldrin spend on the surface of the moon, the MIT team worked to find the source of the problem. Discovering the issue stemming from the rendezvous radar; they ordered Armstrong and Aldrin to turn the radar to another setting and cut its power supply, just in case, so that the astronauts had enough power to get home.

The moon landing had been a success and the Apollo 11 crew got back to Earth safely, thanks to the computer programming of the lunar module – the Eagle and its fail-safe’s. The mission was a success and humankind had landed on the moon.

Hamilton’s Legacy

Margaret Hamilton Receiving the Presidential Medal of Freedom
Margaret Hamilton Receiving the Presidential Medal of Freedom

Hamilton has published over 130 scientific papers and is responsible for having coined the term software engineering to describe her field.

In 2016, Hamilton received the Presidential Medal of Freedom from President Obama. She received the award for her work in developing on-board flight software for NASA’s Apollo moon missions.

In 2017, Hamilton was immortalised as a Lego figure as part of the LEGO Ideas Women of NASA set. Hamilton is featured in this set along side fellow scientists Nancy Grace Roman, Sally Ride and Mae Jemison.


Margaret and the Moon

A true story from one of the Women of NASA!

Dean Robbins and Lucy Knisley deliver a lovely portrayal of a pioneer in her field who never stopped reaching for the stars.

Ages 4-8 years

The Woman in the Moon

A stunning and intimate biography of Margaret Hamilton, the computer engineer who helped Apollo 11 and mankind get from the Earth to the moon. 

Richard Maurer dives deep into the backstory of this extraordinary woman – with first-hand interviews and access to primary sources.

Ages 10-13 years

You might also like

Marie Curie

Marie Curie | Double Nobel Prize Winning Scientist

Marie Curie was an exceptional physicist and chemist working during the 19th and 20th century. Her discoveries led to some of the greatest inventions of the 20th century, such as the development of radiotherapy and the use of nuclear energy.