Flight-control firmware for a fixed-wing VTOL (vertical take-off and landing) aircraft, running on a Teensy microcontroller. It manages the full flight envelope — vertical hover, transition, and horizontal cruise — from onboard sensor fusion, and talks to a ground station over a long-range LoRa radio link.
- MCU: Teensy (Arduino / PlatformIO framework)
- Radio: LoRa @ 915 MHz (RadioHead) for ground-station telemetry and commands
- Sensors: barometer (altitude), GPS (position/heading/speed), magnetometer (heading)
- Actuators: 4× motors, 4× servos
The vehicle runs a small mode state machine and only actuates once armed from the ground:
| Mode | Behavior |
|---|---|
IDLE |
Disarmed; waiting for the ground-station ARM command over LoRa |
VERTICAL |
Hover / vertical control — holds a target altitude (barometer-driven) |
HORIZONTAL |
Cruise — holds target pitch and roll |
Each subsystem is a self-contained module (.cpp/.h pair):
flight_computer.*— central loop; fuses sensors into a singleFlightDatastate (altitude, pitch, roll, yaw, speed, heading, vertical speed, acceleration, per-motor power, per-servo angle)flight_control_vertical.*/flight_control_horizontal.*— the two control loopsbarometer.*,gps.*,magnetometer.*— sensor driversmotors.*,servos.*— actuator outputstelemetry.*— packs state for the LoRa downlinkmain.cpp— init, arming sequence, and the mode dispatcher
Built with PlatformIO:
pio run # build
pio run -t upload # flash to the Teensy
pio device monitor # serial telemetryThe aircraft boots disarmed. Motors and servos stay inert until the ground station sends ARM over the LoRa link, so it can't spin up on the bench by accident.
Working firmware for the core sensing, control, and comms path. This is real flight-controls code — treat any live-vehicle testing with the usual RC/UAV safety practices (props off for bench tests, open field, spotter).