At NASA, the process we call entry, descent, and landing, or EDL, is the series of events that occurs from the time a spacecraft encounters the top of the Martian atmosphere until it safely touches down on the surface. You can model this process using coding languages, such as Python! In this activity, you will program several features of EDL, such as determining your spacecraft's proximity from the surface once it arrives at Mars.

Animation showing the Perseverance Mars rover aeroshell descending on Mars and the parachute deploying


Graphic showing each phase in the Perseverance Mars rover's landing

1. Learn what it takes to land on Mars

Landing a spacecraft on Mars is no easy task. Because of the enormous distance between Earth and Mars, we can't control the spacecraft in real-time like one would in a video game. All of our communications with the spacecraft are limited by the speed of light, so it takes a signal around seven minutes to be sent from Earth to Mars and another seven minutes to come back. As a result, spacecraft have to land autonomously – on their own, based on instructions programmed into their onboard computers.

To successfully land a spacecraft, we send it into space with hundreds of thousands of lines of code, providing instructions for each of the maneuvers it will need to perform to land safely, including:

  • Measuring how far it is from the surface
  • Knowing when to perform each maneuver, such as deploying its parachute
  • Communicating its status with mission controllers on Earth
  • And safely beginning operations upon reaching the surface

About the image: This illustration shows the events that occur in the final minutes of the nearly seven-month journey that NASA’s Perseverance rover takes to Mars. Image credit: NASA/JPL-Caltech | › Full image and caption

2. Get set up

Review each of the tasks you'll need to complete in the steps below to land your spacecraft safely. And get more inspiration by researching how NASA lands spacecraft on Mars. Then, decide what devices you will use to simulate your spacecraft and landing. What tools do you have to indicate successful steps along the landing process? Would you use lights at certain steps? Should the lights be on or off? Could you use sound? Some devices are capable of detecting color – perhaps the color of the Martian landing site? Be as creative as you like and make it your own based on your own ideas, what you have available, and what you’re comfortable with.

Note: Throughout this activity, we’ll provide some sample code and names, but yours will likely vary depending on what you’re using. Just remember to be consistent throughout!


  1. Import your components – Some devices do this automatically while others use an ‘import’ line to call in their library. Every device has its own naming conventions and vocabulary.

Animation showing various gauges from a rover-eye view as the spacecraft touches down

3. Measure the distance between the spacecraft and the surface

As the name suggests, entry, descent, and landing is a multi-step process. For example, engineers program the rover to provide constant feedback about its altimetry – height – as its descending on Mars. Once a spacecraft determines that it is at a certain altitude, it knows to initiate the next phase of the landing sequence.


  1. Determine your landing site – You will determine your “landing goal” based on the devices you’re using to simulate the landing. For example, if you have a small device to use as your spacecraft, you could tie it to a string and lower it off the edge of a table toward the floor. If your device is larger or delicate, you may want to try sliding the device horizontally across the floor toward a wall or standing target.
  2. Set up an ultrasonic sensor – Begin by writing the code to activate your ultrasonic sensor and have it display the distance it’s reading.

  3. Add a light indicator to reflect the measurement – Using LEDs, we can quickly create a visual output to reflect the measurement from the ultrasonic sensor. This can be done using a go-caution-stop pattern, but feel free to make it your own!

About the image: An animated scene from the mission trailer for the Perseverance Mars rover landing. Image credit: NASA/JPL-Caltech | › Watch the trailer | + Expand image
Animation showing the Perseverance Mars rover aeroshell descending on Mars and the parachute deploying

4. Create an alarm for each phase of the landing

The Perseverance rover has a camera beneath it that can measure the distance between it and the Martian surface. This allows the spacecraft to determine when to do each of its landing maneuvers, such as firing retrorockets to further slow the spacecraft's descent.


  1. Transition between stages – Add an alarm system that signals when it's time to move to the next phase of your spacecraft's landing, such as deploying the cables from the skycrane that lower the rover to the ground. A sample audio alert is provided below.

  2. Consider how to adjust to the desired height – The sample code provided above sounds the alarm when our code has reached a certain light and distance reading. Can you modify the code to produce a green light to deploy at the desired distance – not too close and not too far?

About the image: An animated scene from the mission trailer for the Perseverance Mars rover landing. Image credit: NASA/JPL-Caltech | › Watch the trailer | + Expand image 
Artist's concept of the sun shining beyond the horizon of Mars

5. Power up

While the Perseverance and Curiosity rovers are powered by what's known as an RTG, other Mars missions utilize solar power, collecting light through solar panels and converting it into electricity. Once these missions have safely landed, they begin collecting light to power up and begin communicating with scientists back on Earth.


  1. Collect sunlight to power your spacecraft – Using a light sensor or solar panel, we can measure how much sunlight we’re collecting to provide energy to our spacecraft.

  2. Plot your solar-power data – Depending on your device or kit, it might be possible to print a constant readout of how much light your spacecraft is collecting or even plot the data over time. The ability to see this in real time will vary depending on whether your display is on the kit or on your computer.

About the image: An animated scene from the mission trailer for the Perseverance Mars rover landing. Image credit: NASA/JPL-Caltech | › Watch the trailer | + Expand image
Illustration of a Mars rover sending a message back to Earth

6. Phone home

Remember that due to the vast distance between Earth and Mars, we don’t actually know that the mission has landed successfully until it has transmitted its status back to us.


  1. Send a message using sound – Program a buzzer to manually send a message back to Earth, signaling that your spacecraft is safe and powered up. Try having the buzzer sound out a simple message in Morse code. A sample Morse code dictionary can be found in the code snippet below.

  2. Challenge: Send your message in code rather than sound – Sound waves can’t travel through the void of space, so we can’t use sound to have the spacecraft transmit its safe status back to Earth. Instead, we can have the spacecraft write its message in Morse code, then transmit that message back to us using light.

    This is similar to how we communicate with spacecraft through NASA's Deep Space Network, or DSN. Data is converted to binary code (ones and zeros) by computers and transmitted as light waves from spacecraft to the giant satellite dishes that make up the DSN.

About the image: A animated scene from the Mars in a Minute video "Phoning Home – Communicating From Mars." Image credit: NASA/JPL-Caltech | › Watch video | + Expand image
Artist's concept of the skycrane device lowering the Perseverance Mars rover onto the surface

7. Bring it all together

As we learned, due to the distance between Earth and Mars, our code has to run autonomously. So once EDL begins, our code has to execute on its own from start to finish.


String your code into one sequence – As a final challenge, see if you can edit your code to do all of the following in sequence:

  1. Measure the distance from the surface, moving from a red LED (too high to deploy) to a yellow LED to a green LED (desired height to deploy).
  2. Once your spacecraft reaches the desired height from the surface (green light), have it play a sound.
  3. Upon playing the sound indicating it has landed safely, begin collecting light.
  4. After 30 seconds of collecting light, prompt for a message in Morse code to transmit back to Earth.
  5. Once the Morse code output has been received (manually or pre-programmed) have your program quit operations (turn off LEDs and quit collecting light).

About the image: An illustration of NASA’s Perseverance rover landing safely on Mars. Image credit: NASA/JPL-Caltech | › Full image and caption