Image copyright AP Image caption Margaret Hamilton was a lead software developer for Nasa's Apollo Moon missions in the 1960s

An 80-year-old woman who wrote software for the Apollo space missions has been given the United States' highest civilian honour, the Presidential Medal of Freedom.

Margaret Hamilton was one of 21 people awarded the medal by President Barack Obama in a star-studded ceremony.

It is almost 50 years since her initial work on the Apollo 11 moon mission.

Mrs Hamilton's pioneering software helped land the lunar module and its crew on the Moon in 1969.

Other notable medal recipients at Tuesday's ceremony at the White House included comedian and talkshow host Ellen DeGeneres, actor Tom Hanks and musicians Diana Ross and Bruce Springsteen.

President Obama said Mrs Hamilton "symbolises that generation of unsung women who helped send humankind into space".

Astronauts Neil Armstrong and Buzz Aldrin may have garnered many of the headlines after Apollo 11's successful landing, but Mrs Hamilton was among those working behind the scenes at time when computer science was so new it was not even a recognised term, and code was written out by hand.

Image copyright Getty Images Image caption US President Barack Obama awards the Medal of Freedom to computer software pioneer Margaret Hamilton

Mrs Hamilton led a team at the Massachusetts Institute of Technology that created the on-board flight software for Nasa's moon missions.

One small tweak for mankind?

"Our astronauts didn't have much time, but thankfully they had Margaret Hamilton," President Obama said, as he awarded her the medal.

He was referring to a tweak Mrs Hamilton made to the Apollo system which enabled the computer to prioritise commands when overloaded with tasks.

Her work proved vital on the day: minutes before the lunar lander reached the Moon's surface on 20 July 1969, several computer alarms were triggered. But, thanks to Mrs Hamilton's foresight, the Nasa team was able to see that the alert was nothing critical, and the landing went ahead.

"If the computer hadn't recognized this problem and taken recovery action, I doubt if Apollo 11 would have been the successful moon landing it was," wrote Mrs Hamilton in 1971.

Image copyright MIT Museum

Mrs Hamilton was a 24-year-old maths graduate when she got a job at MIT. She planned for it to be temporary step, while supporting her husband who was studying law at Harvard University. She then intended to go back to her own studies.

However when MIT was asked to work on the Apollo space program, she joined the team and was hooked in an exciting new field.

A working mother in the 'Wild West'

In an interview with Wired magazine in 2015, Mrs Hamilton admitted that being a working mother in the 1960s brought additional challenges and she often took her daughter, then four years old, into the lab.

She also noted that in this new world of computing, there were no footsteps to follow in. "When I first got into it, nobody knew what it was that we were doing.

"It was like the Wild West. There was no course in it. They didn't teach it," she said.

Yet she and her MIT colleagues went on to write the code for the world's first portable computer.

From the 1970s onwards, she used her expertise to found her own software businesses, including Hamilton Technologies, which is still based in Massachusetts.

Image copyright Getty Images Image caption Margaret Hamilton at the White House ceremony with a fellow recipient of the Presidential Medal of Freedom, actor Tom Hanks (centre), who starred in the Apollo 13 film

Mr Obama also hailed the Indiana-born mathematician for developing software architecture that "echoes in countless technologies today" and said she encapsulated the "American spirit of discovery that exists in every little girl and little boy".

Rear Admiral Grace Hopper was also awarded the medal, posthumously. Mr Obama said the computer scientist, who died in 1992, was at the forefront of computers and programming development from the 1940s to 1980s.

President Obama hailed the 21 honourees as "extraordinary Americans who have lifted our spirits, strengthened our union, pushed us toward progress".