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
None
This project requires electronic circuit parts. See Materials list for details.
No issues
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)!
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:
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
- Altitude
- Sensor
- Radar
- Laser altimeter
- Ultrasonic distance sensor
- Ultrasonic sound
- Sonar
- Echolocation
Questions
- What are some methods that real spacecraft use to land safely on other planets?
- Why is it important for a spacecraft to know its altitude during descent?
- What are the different outputs you can program on a micro:bit?
Bibliography
- NASA (2024, August 7). Here's How Curiosity's Sky Crane Changed the Way NASA Explores Mars. Retrieved October 10, 2024
- Micro:bit Educational Foundation (n.d.). Getting Started. Retrieved June 7th, 2024
- Science Buddies staff (n.d.). Engineering Design Process. Retrieved August 19, 2024
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.
- Computer with USB port
- micro:bit Go Bundle. This kit contains everything you will need to get started working with micro:bit:
- micro:bit board
- micro-USB to USB-A cable (you will need an adapter if your computer has a USB-C port)
- 2xAAA battery holder
- AAA batteries (2)
- 3V-compatible HC-SR04 ultrasonic distance sensor, like this one from Adafruit or this one from SparkFun. Important: some ultrasonic distance sensors require a 5V power supply and will not work with the micro:bit. Make sure you order one that is listed as 3V-compatible.
- Male to female jumper wires (4) to connect to the ultrasonic sensor
- Alligator clip leads (4) to connect to the micro:bit
- Craft supplies to build your lander, such as:
- Cardboard box
- Shock-absorbing materials like cotton balls, springs, etc.
- Materials to build a parachute, like a plastic bag and string
- Scissors
- Tape
- Glue
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
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.
- 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.
- 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.
- 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.
- 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.
- 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.
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.
- 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.
- Decide what programming language you will use for your micro:bit:
- 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.
- 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.
- 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.
- Click
Variables
in the blocks menu, thenMake a Variable...
, and create a new variable calleddistance
. - 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. - Click on
Variables
in the blocks menu. Drag out aset distance to 0
block and snap it into theforever
loop. - Click on
Sonar
in the blocks menu. Drag out the block so it replaces the0
in theset distance to 0
block. Change the drop-down menus as follows:- ping trig
P0
- echo
P1
- unit
cm
- ping trig
- Click on
Advanced
in the blocks menu.- Click on
Serial
. - Drag out a
serial write value "x" = 0
block and snap it below yourset distance to
block. - Replace the text "x" with "distance (cm)".
- Click on
Variables
in the blocks menu. Drag out thedistance
variable and use it to replace the0
.
- Click on
- Click
- 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
orAdvanced
/Control
(you may need to selectMore
to find the blocks).
- Place your ultrasonic sensor flat on the table so it is facing upward.
- Download the code to your micro:bit.
- 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. - 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:
- Make sure you have connections to the correct pins as shown in Figures 2 and 3.
- Make sure you do not have any short circuits and that the metal parts of the alligator clips are not bumping into each other.
- 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.
- 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.- 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.
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:
- Your lander needs to hold your micro:bit, ultrasonic sensor, cables, and 2xAA battery pack without letting them fall out.
- Your lander should probably have features that slow it down during descent, like parachutes or streamers.
- Your lander should also have features that help absorb some of the impact when it hits the ground.
- You will need to make sure your ultrasonic sensor can face downward, with an unobstructed "view" of the ground.
- Figures 7 and 8 show an example lander with the following features, but your design can be different:
- A cardboard box holds the payload.
- Two circular holes are cut in the bottom of the cardboard box so the ultrasonic sensor can face downward.
- A plastic bag acts as a parachute and is tied to the four corners of the cardboard box with string.
- Cotton balls glued to the bottom of the box act as shock absorbers for the landing.
- 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.
- 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?
- Test your lander from higher drop heights, for example, by standing on a chair or table (with adult supervision).
- Once you are ready to test with your micro:bit, move on to the next section.
Put It All Together
- Unplug your micro:bit from your computer.
- Plug the 2xAA battery pack into the micro:bit.
- 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:
- Make sure you are using fresh batteries.
- Make sure you have not created any short circuits when moving the micro:bit and cables around.
- Pack your electronics into your lander (Figure 9).
- Remember to make sure the ultrasonic sensor has an unobstructed downward view.
- 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.
- Test your lander by holding it and lowering it slowly toward the ground. Does the output that you programmed trigger properly?
- 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:
- 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).
- 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).
- 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.
- What other features can you add to your lander? See the Variations section for more ideas.
Ask an Expert
Global Goals
The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.
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:
Related Links
- Science Fair Project Guide
- Other Ideas Like This
- Space Exploration Project Ideas
- Robotics Project Ideas
- Electricity & Electronics Project Ideas
- My Favorites