Chapter 6: Space Defense

Day 28: Landing Gear

Video lesson · 40 min

Deploy the landing gear. Wire servo motors for mechanical control of the docking system. Three switches arm in sequence before approach can begin. Learn servo positioning, sequential activation logic, and mechanical safety interlocks.

Mission Critical: Landing Gear Deployment

The mother ship's hull gleams silver against the star field, close enough now that you can make out the docking bay's approach lights blinking in sequence. After twenty-eight days of jury-rigged systems and improvised solutions, home is finally within reach. But one critical system remains offline: the landing gear.

Without the original flight computer, the lander's hydraulic gear system is dead weight. The mechanical backup exists, but it requires manual control from the cockpit. Three switches must be armed in sequence before the approach can begin. Then, as you guide the craft into the docking bay, two buttons will control the gear: one to extend, one to retract. A single mistake could mean bouncing off the mother ship's hull and drifting into the void.

Your makeshift control panel needs one final upgrade. The 16-button matrix you salvaged will serve as your gear controls, while the OLED display shows real-time gear position through animated bitmaps. The three DIP switches become your preflight safety system. All switches must start in the OFF position, then all must be switched ON to arm the approach sequence.

Through the viewport, the docking bay grows larger. This is it. The final approach to salvation depends on the precision of your code and the reliability of your circuits. No room for error. No second chances.

What You'll Learn

When you complete this lesson, you'll be able to:

• Create state machines using enums to manage complex sequences

• Use analog pins as digital inputs when you run out of digital pins

• Organize large bitmap arrays for animated graphics

• Handle multiple input devices (switches and button matrix) in one program

• Create include files to keep your code organized and readable

• Display different screens based on program state

Understanding State Machines

Think of a vending machine. It has distinct states: waiting for money, dispensing product, giving change. Each state has specific behaviors and specific conditions that move it to the next state. Your landing gear system works the same way.

Our approach sequence has three states: INIT (checking that all switches are off), PREFLIGHT (waiting for all switches to turn on), and FINAL (allowing gear control). Each state displays different information on the screen and responds to different inputs. The program can only move from one state to the next when specific conditions are met.

State machines prevent dangerous transitions. You can't accidentally deploy landing gear during preflight checks, and you can't start the approach sequence until all safety systems are confirmed. This is how real spacecraft systems work: every critical operation requires passing through a series of verified states.

The gear animation uses a different kind of state tracking. Instead of program states, we track the gear's physical position through four bitmap images: fully retracted, partially extended, mostly extended, and fully deployed. Button presses change which bitmap displays, creating the illusion of moving landing gear.

Wiring Your Landing Control System

Wiring diagram for landing gear control system

This circuit combines everything you've learned: OLED display, button matrix, DIP switches, and seven-segment display. Notice we're using analog pins A0, A1, and A2 as digital inputs for the DIP switches.

  1. DIP switches to analog pins: When you run out of digital pins, analog pins can read digital HIGH/LOW signals just fine
  2. Button matrix spans pins 6-13: The keypad library handles the complex scanning automatically
  3. OLED uses I2C: Only needs power and two communication lines (SDA/SCL)
  4. Seven-segment display: Uses pins 2 and 3 for communication with the TM1637 chip

The Complete Landing Gear Code

Since this is a complex program with multiple systems working together, here's the complete code first. Copy this into your controller, then we'll break down how it works:

This is lesson 29 of 31 in 30 Days Lost in Space — a professionally produced Arduino course taught by Dr. Greg Lyzenga (NASA JPL scientist, Harvey Mudd professor). Each lesson features cinematic-quality video produced with a 20-30 person professional crew.

All video lessons are free to watch. Get the kit at craftingtable.com — $100 with a 30-day money-back guarantee.