Arduino Controlled Landing Reusable Rocket - With Tinkercad Simulation

by ahmedebeed555 in Circuits > Arduino

777 Views, 5 Favorites, 0 Comments

Arduino Controlled Landing Reusable Rocket - With Tinkercad Simulation

Arduino Rocket.jpg

Who doesn't remember this moment in history when the 2 synchronized SpaceX rockets landed together?

My son had his own school project with this cool idea.

This step‑by‑step Instructable shows how to build a demo soft‑landing system using an Arduino, an HC‑SR04 ultrasonic sensor, two DC motors driven by an H‑bridge, and a landing indicator LED. The system measures distance to the ground and adjusts motor speed with PWM so the rocket/device descends gently and stops when close to ground.

The project demonstrates a simple control loop that uses an ultrasonic sensor to measure altitude and PWM motor control to implement a staged descent. It’s a great educational demo for understanding sensors, motor control, and feedback loops. You can use it in STEM workshops, classroom demos, or as part of a model rocket/rotorcraft prototype.

What you will learn:

  1. How to read distance using an HC‑SR04 ultrasonic sensor.
  2. How to control two DC motors using PWM and an H‑bridge driver.
  3. How to implement staged control logic for soft landing.
  4. How to debug sensor noise and add smoothing/hysteresis.

Estimated build time: ~ 40 minutes (depending on assembly and testing).

Supplies

circuit.jpg

Components (Bill of Materials)

Qty Item

1 Arduino Uno (or compatible)

1 HC‑SR04 ultrasonic sensor

For distance measurement

1 H‑bridge motor driver (L298N or L293D)

Supplies motor direction & PWM control

2 DC motors

Small brushed DC motors (3–6V)

1 5V LED

Landing indicator

1 External motor power supply

e.g. 9V battery pack or bench PSU (match motors)

Assorted Jumper wires, breadboard, screws, mount For assembly


Safety note: Use a separate power supply for motors. Motors can draw high current and cause voltage dips or damage the Arduino if powered from the Arduino 5V rail.

Circuit Connection

Connection.jpg
The wiring below assumes an H‑bridge that has separate EN (enable/PWM) pins and IN pins for direction (common for L298N and similar drivers). Check your driver's datasheet and adapt pins accordingly.

Pin mapping used in software

  1. motorPin1A (IN1) → Arduino pin 9
  2. motorPin1B (IN2) → Arduino pin 10
  3. motorPin2A (IN3) → Arduino pin 11
  4. motorPin2B (IN4) → Arduino pin 12
  5. enA (ENA PWM) → Arduino pin 3 (PWM)
  6. enB (ENB PWM) → Arduino pin 5 (PWM)
  7. trigPin → Arduino pin 8
  8. echoPin → Arduino pin 7
  9. ledLanding → Arduino pin 13

Wiring steps

  1. Power
  2. Connect the H‑bridge motor supply input to your external motor battery (observe polarity).
  3. Connect the H‑bridge ground to the Arduino GND (common ground is required).
  4. If your H‑bridge has a 5V regulator output and you intend to power Arduino from it, read the module manual carefully — usually it’s safer to power Arduino separately or from USB for programming.
  5. Motors
  6. Connect Motor A wires to the H‑bridge motor outputs A.
  7. Connect Motor B wires to the H‑bridge motor outputs B.
  8. Control pins
  9. Wire IN1 → Arduino 9; IN2 → Arduino 10; IN3 → Arduino 11; IN4 → Arduino 12.
  10. Wire ENA → Arduino 3 (this will receive analogWrite() PWM signals).
  11. Wire ENB → Arduino 5 (PWM).
  12. Ultrasonic sensor
  13. Vcc → 5V (Arduino)
  14. GND → GND
  15. TRIG → Arduino 8
  16. ECHO → Arduino 7
  17. LED
  18. Connect LED anode (long leg) to Arduino 13 (or to a 220Ω resistor then to pin 13).
  19. Connect LED cathode to GND.
  20. Serial Monitor
  21. Connect Arduino to your computer via USB so you can view debug prints at 9600 baud.

Wiring tips & noise mitigation

  1. Place a 0.1µF ceramic capacitor close to the motor power input to filter high‑frequency noise.
  2. If motors produce heavy interference, add 100µF electrolytic across motor supply and small RC snubbers across motor terminals.
  3. Keep the ultrasonic wiring short to reduce signal noise.


Arduino Code

Arduino Code.jpg

Arduino Code

Copy the following code into the Arduino IDE and upload to your board. Adjust PWM pins or thresholds if your motors behave differently.
// Define pins for components
const int motorPin1A = 9; // Motor 1 IN1
const int motorPin1B = 10; // Motor 1 IN2
const int motorPin2A = 11; // Motor 2 IN3
const int motorPin2B = 12; // Motor 2 IN4
const int enA = 3; // Enable pin for Motor 1 (PWM)
const int enB = 5; // Enable pin for Motor 2 (PWM)
const int echoPin = 7; // Echo pin for the ultrasonic sensor
const int trigPin = 8; // Trigger pin for the ultrasonic sensor
const int ledLanding = 13; // LED to indicate landing success

void setup() {
pinMode(motorPin1A, OUTPUT);
pinMode(motorPin1B, OUTPUT);
pinMode(motorPin2A, OUTPUT);
pinMode(motorPin2B, OUTPUT);
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(ledLanding, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}

void loop() {
long distance = getDistance();
Serial.print("Distance to ground: ");
Serial.println(distance);

if (distance > 50) {
// High altitude - full speed
digitalWrite(motorPin1A, HIGH);
digitalWrite(motorPin1B, LOW);
digitalWrite(motorPin2A, HIGH);
digitalWrite(motorPin2B, LOW);
digitalWrite(ledLanding, LOW);
analogWrite(enA, 255);
analogWrite(enB, 255);
} else if (distance > 10 && distance <= 50) {
// Medium altitude - reduce speed
digitalWrite(motorPin1A, HIGH);
digitalWrite(motorPin1B, LOW);
digitalWrite(motorPin2A, HIGH);
digitalWrite(motorPin2B, LOW);
digitalWrite(ledLanding, LOW);
analogWrite(enA, 128);
analogWrite(enB, 128);
} else if (distance <= 10) {
// Low altitude - soft landing
digitalWrite(motorPin1A, HIGH);
digitalWrite(motorPin1B, LOW);
digitalWrite(motorPin2A, HIGH);
digitalWrite(motorPin2B, LOW);
digitalWrite(ledLanding, LOW);
analogWrite(enA, 50);
analogWrite(enB, 50);

if (distance <= 5) {
analogWrite(enA, 0);
analogWrite(enB, 0);
digitalWrite(ledLanding, HIGH);
Serial.println("Landing complete. Motors stopped.");
}
}

delay(100);
}

long getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
long distance = duration * 0.034 / 2;
return distance;
}


Tinkercad Simulation

Tinkercad Simulation.jpg

Tinkercad is a great place to simulate the circuit before building it physically. Follow these steps to build the simulation:

  1. Go to [Tinkercad Circuits] and create a new Circuit project.
  2. Drag an Arduino Uno and place it on the workspace.
  3. Add an HC‑SR04 ultrasonic sensor and connect Vcc→5V, GND→GND, TRIG→pin 8, ECHO→pin 7.
  4. Add an H‑bridge (L298N) or two motor drivers (Tinkercad includes L293D toggle) and place two small DC motors.
  5. Wire motor driver IN/EN pins to Arduino pins as per the pin mapping in the "Circuit Connection" section.
  6. Place an LED and connect through a 220Ω resistor to pin 13 and GND.
  7. Copy/paste the Arduino code into the Tinkercad code editor (select Arduino mode) and upload to run.

Simulation tips:

  1. Tinkercad's motor models are simplified; use the serial monitor and printed distances to validate logic.
  2. Use Tinkercad’s variable resistor or button to emulate ground proximity if you need precise test cases.









Final and Future Work

Final

  1. You now have a working demonstration of a soft‑landing controller that stages motor speed by altitude and indicates when landing is complete.
  2. Use the serial monitor to calibrate the altitude thresholds for your particular motors and setup.

Future improvements and extensions

  1. Add smoothing/hysteresis: Average multiple distance samples to reduce noise and prevent jitter near thresholds.
  2. PID control: Replace the simple threshold logic with a PID loop to compute motor PWM smoothly based on distance error and rate of descent.
  3. Altitude sensor upgrade: Use a laser rangefinder or barometric sensor for more precise altitude measurement in real applications.
  4. Logging & telemetry: Add an SD card or radio link to log descent profile and motor outputs for analysis.
  5. Safety features: Implement an emergency cut‑off if sensors fail or if descent rate is too high.


Troubleshooting

  1. Distance reads 0 or very large: Check the HC‑SR04 power and wiring; ensure echo pin is connected and nothing blocks the sensor.
  2. Motors don't spin: Verify motor power supply, common ground, and that EN pins receive PWM. Test motors directly with battery.
  3. Excessive noise or MCU resets: Motors may be drawing too much current—add decoupling capacitors and confirm the power supply can deliver the current.