Jump to main content

Build a Model Planetary Lander with micro:bit

1
2
3
4
5
28 reviews

Abstract

How do you make a spacecraft land safely on the Moon or another planet like Mars? It probably helps to know how far away the ground is so you can deploy landing gear, activate a parachute, or fire thrusters to help slow down. In this project you will build your own "lander" vehicle with a sensor that can measure distance to the ground, allowing you to program outputs like blinking lights or an audible alarm. 

Summary

Areas of Science
Difficulty
 
Method
Time Required
Short (2-5 days)
Prerequisites

None

Material Availability

This project requires electronic circuit parts. See Materials list for details.

Cost
Low ($20 - $50)
Safety

No issues

Credits
Science Buddies is committed to creating content authored by scientists and educators. Learn more about our process and how we use AI.

Objective

Design a model spacecraft lander that uses an ultrasonic sensor to measure the distance to the ground. 

Introduction

Humans have built spacecraft that have landed on a variety of celestial bodies in our solar system, including moons, planets, and even asteroids. These spacecraft can carry human astronauts, autonomous robots, or scientific payloads like equipment that measures the local atmosphere. Engineers have employed a variety of methods to land these valuable payloads safely, including retrorockets (rockets that fire to slow a vehicle down instead of speed it up), parachutes, airbags, and even hovering sky cranes that gently lower the payload to the surface (Figure 1)!

Figure 1. Illustration of the Mars rover Perseverance being lowered to the Martian surface by a sky crane.

Most of these methods have something in common: they need to know the lander's altitude, or vertical distance from the ground. If you fire retrorockets too early or deploy a parachute too late, it may result in a crash landing that destroys the payload. Since other moons and planets do not have the same infrastructure we have here on Earth to pinpoint location - like cell towers and GPS satellites - the landers must rely on onboard electronic sensors to determine their altitude. Such sensors include radar and laser altimeters that send out a signal (an electromagnetic wave) down toward the surface, and measure the amount of time it takes for the reflected signal to bounce back. If you know the speed at which the signal travels, you can then use this measured time to calculate the distance using the equation:

Equation 1:

In this project, you will use an ultrasonic distance sensor which operates using a similar principle. Instead of electromagnet waves, it emits a short burst of ultrasonic sound (sound that is too high-pitched for humans to hear). The sensor measures how long it takes for the sound wave to reflect back, and by measuring this time, it can calculate the distance. This is the same method that animals like bats use to find objects (like insects) without seeing them - also called sonar or echolocation.

You will use a small programmable board called a micro:bit (note that it is spelled "micro:bit," not micro bit or microbit) to interface with an ultrasonic sensor. The micro:bit has a built-in buzzer and grid of LEDs that you can program as outputs that react to the ultrasonic sensor's reading. See the Variations section for even more ideas, like adding motors for deployable landing gear. Now get ready to design your lander!

Terms and Concepts

Questions

Bibliography

Materials and Equipment

Since this is an engineering design project, the exact parts you need to purchase may vary. Links are provided as examples - parts may be available from multiple vendors, including Home Science Tools®, Adafruit Electronics, SparkFun Electronics, and Amazon. You can try to order all of your parts from a single vendor to minimize shipping costs, but sometimes parts may be out of stock at one vendor. Be sure to read product descriptions carefully when purchasing electronics parts on Amazon.

Disclaimer: Science Buddies participates in affiliate programs with Home Science Tools®, Amazon.com, Carolina Biological, and Jameco Electronics. Proceeds from the affiliate programs help support Science Buddies, a 501(c)(3) public charity, and keep our resources free for everyone. Our top priority is student learning. If you have any comments (positive or negative) related to purchases you've made for science projects from recommendations on our site, please let us know. Write to us at scibuddy@sciencebuddies.org.

Experimental Procedure

This project follows the Engineering Design Process. Confirm with your teacher if this is acceptable for your project, and review the steps before you begin.

In this procedure, you will connect the ultrasonic sensor to your micro:bit and test your code before you build your model planetary lander. This will make it easier to identify any problems with your circuit or code. Once you have everything working, you will build and test a lander designed to protect your micro:bit.

Assemble Your Circuit

Connect the ultrasonic distance sensor's pins to the micro:bit's pins as follows and as shown in Figure 2. Note that Figure 2 shows single wires connecting the pins to make the connections easier to see, but you will need to connect male-female jumper wires to the ultrasonic sensor's pins, and then use alligator clips to connect them to the micro:bit's pins, as shown in Figure 3.

  1. Connect the ultrasonic sensor's Vcc pin to the micro:bit's 3V pin. This connection provides power to the sensor from the micro:bit.
  2. Connect the ultrasonic sensor's Trig pin to micro:bit pin 0. This connection sends a signal, or "trigger," from the micro:bit to activate the sensor.
  3. Connect the ultrasonic sensor's Echo pin to micro:bit pin 1. This connection allows the micro:bit to receive a signal back from the sensor.
  4. Connect the ultrasonic sensor's Gnd pin to the GND pin on the micro:bit. Electrical circuits require a "common ground" to form a closed circuit and allow electricity to flow properly. 
  5. Make sure none of the exposed metal ends of the jumper wires or alligator clips bump into each other. This can create a short circuit, prevent your sensor from working, and possibly damage your sensor or micro:bit.
Figure 2. Connections between the micro:bit and ultrasonic sensor.

Figure 3. Jumper wires and alligator clips connecting the micro:bit to the ultrasonic sensor.

Write and Test Your Code

Note: leave your micro:bit plugged into your computer with the USB cable while you test your code. That way, your micro:bit will get its power through the USB cable and will not drain the batteries. The batteries can drain quickly and prevent your sensor from working properly, so save them for actual drop tests of your lander.

  1. If this is your first time using a micro:bit, follow the Getting Started instructions on the micro:bit website to learn how to use your micro:bit and connect it to your computer. 
  2. Decide what programming language you will use for your micro:bit:
    1. If you are new to coding, we recommend using Microsoft MakeCode to program your micro:bit. MakeCode is a graphical programming language where you make computer programs using colored blocks of code instead of a text editor. The example code in this procedure uses MakeCode. We recommend following a few of the MakeCode tutorials before you proceed.
    2. You can also program your micro:bit in Python, JavaScript, or Scratch. You may prefer this approach if you already have programming experience in one of these languages. See the Let's Code page for more details.
  3. Create a program like the one in Figure 4. This program will take a reading from the ultrasonic sensor and display it in your web browser while your micro:bit is connected to your computer.
    1. Click Variables in the blocks menu, then Make a Variable..., and create a new variable called distance.
    2. Click Extensions in the blocks menu. Search for "sonar" on the new page that opens. Click on the Sonar extension to add it to your project. If you cannot find the Sonar extension, go to step 4.
    3. Click on Variables in the blocks menu. Drag out a set distance to 0 block and snap it into the forever loop.
    4. Click on Sonar in the blocks menu. Drag out the block so it replaces the 0 in the set distance to 0 block. Change the drop-down menus as follows:
      1. ping trig P0
      2. echo P1
      3. unit cm
    5. Click on Advanced in the blocks menu.
      1. Click on Serial
      2. Drag out a serial write value "x" = 0 block and snap it below your set distance to block.
      3. Replace the text "x" with "distance (cm)".
      4. Click on Variables in the blocks menu. Drag out the distance variable and use it to replace the 0.
  4. Alternatively, if you cannot find the Sonar extension, you can write the code to interface with the ultrasonic sensor yourself, as shown in Figure 5. Many of the blocks required to make this program are available under Advanced / Pins or Advanced / Control (you may need to select More to find the blocks).
Figure 4. Makecode program to read the ultrasonic sensor using the built-in Sonar extension.

Figure 5. Custom program to read the sensor without using the Sonar extension.
  1. Place your ultrasonic sensor flat on the table so it is facing upward.
  2. Download the code to your micro:bit.
  3. Click Show data Device in Makecode. This will open the serial monitor, which should display both a graph and a numerical value for the distance reading in centimeters.
  4. Hold your hand directly over the sensor and move it up and down. You should see the distance values change. If the values do not change, or do they do not seem realistic:
    1. Make sure you have connections to the correct pins as shown in Figures 2 and 3.
    2. Make sure you do not have any short circuits and that the metal parts of the alligator clips are not bumping into each other.
    3. Make sure you have changed the drop-down menus in your code to use the correct pins, as shown in either Figure 4 or 5 depending on which version of the program you wrote. 
  5. Once your sensor is working, modify your code to trigger an output based on the distance. This is an open-ended part of the project and you could program multiple outputs or actions at different distances. Figure 6 shows simple example code that uses an if else block to play a buzzing sound when the sensor detects a distance less than 20 cm. Test your code to make sure it works before you continue. 
    1. Note: the micro:bit might not have enough power to light up lots of LEDs and use the ultrasonic sensor at the same time. Try starting with just one or two LEDs, test to make sure the sensor still works properly, and then gradually add more. 
Figure 6. Example code to play a tone below a certain threshold distance.

Build and Test Your Lander

Now that you have your circuit and code working, it is time to build and test a lander. If you have ever done an egg drop project, this is similar - except instead of trying to protect an egg, you need to protect your valuable payload (your micro:bit)! Here are some things to consider for your design:

  1. Your lander needs to hold your micro:bit, ultrasonic sensor, cables, and 2xAA battery pack without letting them fall out.
  2. Your lander should probably have features that slow it down during descent, like parachutes or streamers.
  3. Your lander should also have features that help absorb some of the impact when it hits the ground.
  4. You will need to make sure your ultrasonic sensor can face downward, with an unobstructed "view" of the ground.
  5. Figures 7 and 8 show an example lander with the following features, but your design can be different:
    1. A cardboard box holds the payload.
    2. Two circular holes are cut in the bottom of the cardboard box so the ultrasonic sensor can face downward.
    3. A plastic bag acts as a parachute and is tied to the four corners of the cardboard box with string.
    4. Cotton balls glued to the bottom of the box act as shock absorbers for the landing. 
  6. To avoid damage to your micro:bit during initial testing, put another object, like a toy or small rock, in your lander to use as a payload.
  7. Test your lander starting with low drop distances (just holding it out in front of you). Watch how hard it hits the ground, and look out for other problems, like parachutes not deploying. Can you think of ways to improve your lander?
  8. Test your lander from higher drop heights, for example, by standing on a chair or table (with adult supervision).
  9. Once you are ready to test with your micro:bit, move on to the next section.
Figure 7. Top view of cardboard box lander with plastic bag parachute.

Figure 8. Bottom view of lander with cotton ball shock absorbers and holes cut for the ultrasonic sensor.

Put It All Together

  1. Unplug your micro:bit from your computer. 
  2. Plug the 2xAA battery pack into the micro:bit.
  3. Move your hand back and forth in front of your ultrasonic sensor to make sure your circuit still works. If your circuit does not work properly:
    1. Make sure you are using fresh batteries.
    2. Make sure you have not created any short circuits when moving the micro:bit and cables around.
  4. Pack your electronics into your lander (Figure 9).
    1. Remember to make sure the ultrasonic sensor has an unobstructed downward view.
    2. Take care not to create short circuits when bundling the cables up to fit them in your lander. If needed, you can wrap the exposed metal parts in tape to help prevent short circuits. You can also use twist ties or zip ties to help organize your cables.
Figure 9. micro:bit, battery pack, and ultrasonic sensor packed into the cardboard box lander. The ultrasonic sensor is facing downward through holes cut in the box.
  1. Test your lander by holding it and lowering it slowly toward the ground. Does the output that you programmed trigger properly? 
  2. Carefully drop-test your lander. Start from a low height and drop onto a soft surface like carpet, a couch, or a pillow. Does your output seem to trigger at the correct height? If it seems like your lander falls too fast and the output triggers too late:
    1. Try increasing the distance at which you trigger the output to give the micro:bit more time to a react (there is a limit to how fast it can take sensor readings).
    2. Remove any unnecessary code to speed up your program (for example, serial write blocks do not do anything useful when the micro:bit is not connected to your computer).
  3. Gradually try increasing your drop height and testing your lander again. To avoid damage to your micro:bit, avoid dropping onto hard surfaces or from very high locations. 
  4. What other features can you add to your lander? See the Variations section for more ideas. 
icon scientific method

Ask an Expert

Do you have specific questions about your science project? Our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Global Goals

The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.

This project explores topics key to Industry, Innovation and Infrastructure: Build resilient infrastructure, promote sustainable industrialization and foster innovation.

Variations

  • Can you change your code to take different actions at different altitudes, or stages of descent? For example, you could play a progressively higher-pitched sound as your lander gets closer to the ground, or display a different pattern on the LED grid. 
  • Can you change your code to do something different (for example, automatically turn off the buzzer) once your device has landed?
  • Can you add servo motors to your lander to deploy landing gear? You will need to look up how to control servo motors with your micro:bit. See our mini solar tracker project for an example. Note that motors will require an additional external battery pack, which will make your lander heavier. 
  • Can you do this project with another microcontroller like an Arduino instead of a micro:bit? The Arduino and the required batteries are bigger and heavier, so you may need to improve your lander's design to avoid a crash-landing. 
  • The micro:bit has a built-in accelerometer. Can you use the accelerometer to detect when your lander is in free fall and when it contacts the ground?
  • Use the radio communication feature to communicate with another micro:bit that acts as a base station. Can you receive data from the falling micro:bit and/or send commands to it?

Careers

If you like this project, you might enjoy exploring these related careers:

Career Profile
Have you watched "The Transformers" cartoon series or seen the "Transformers" movies? Both shows are about how good and evil robots fight each other and the humans who get in the middle. Many TV shows and movies show robots and humans interacting with each other. While this is, at present, fantasy, in real life robots play a helpful role. Robots do jobs that can be dangerous for humans. For example, some robots defuse landmines in war-stricken countries; others work in harsh environments like… Read more
Career Profile
Humans have always longed to fly and to make other things fly, both through the air and into outer space—aerospace engineers are the people that make those dreams come true. They design, build, and test vehicles like airplanes, helicopters, balloons, rockets, missiles, satellites, and spacecraft. Read more

News Feed on This Topic

 
, ,

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Finio, Ben. "Build a Model Planetary Lander with micro:bit." Science Buddies, 25 Oct. 2024, https://www.sciencebuddies.org/science-fair-projects/project-ideas/SpaceEx_p047/space-exploration/microbit-mars-lander. Accessed 16 June 2025.

APA Style

Finio, B. (2024, October 25). Build a Model Planetary Lander with micro:bit. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/SpaceEx_p047/space-exploration/microbit-mars-lander


Last edit date: 2024-10-25
Top
We use cookies and those of third party providers to deliver the best possible web experience and to compile statistics.
By continuing and using the site, including the landing page, you agree to our Privacy Policy and Terms of Use.
OK, got it
Free science fair projects.