Jump to main content

Program Drone Steering with an Arduino®

1
2
3
4
5
5 reviews

Summary

Active Time
2-3 hours
Total Project Time
2-3 hours
Key Concepts
Circuits, programming, forces
Credits
Ben Finio, PhD, Science Buddies
Arduino is a registered trademark of Arduino LLC.
DIY Mini Drone Part 4: Program Drone Steering with Arduino

Introduction

How do quadcopters (drones with four propellers) steer? Find out in this fun project as you program an Arduino to steer a mini popsicle stick drone!

See this page for a complete list of our mini drone projects. You may wish to do the projects in order.

This activity is not recommended for use as a science fair project. Good science fair projects have a stronger focus on controlling variables, taking accurate measurements, and analyzing data. To find a science fair project that is just right for you, browse our library of over 1,200 Science Fair Project Ideas or use the Topic Selection Wizard to get a personalized project recommendation.

Materials

Notes about using an Arduino:

  • The list below shows all the individual parts you need to purchase to do this project. An Arduino starter kit, like the Elegoo UNO Super Starter Kit, may be worth it if you plan to do more Arduino projects in the future. They contain many of the parts you will need for this and other projects. If you decide to purchase a starter kit, make sure you check this project's materials list for other parts you might still need to purchase separately. Note that since the Arduino project is open source, some starter kits contain third-party Arduino-compatible boards with equivalent functionality.
  • You have several options when it comes to programming your Arduino. You can install the Arduino Integrated Development Environment (IDE) locally on your computer by following the instructions for your operating system on the Arduino software page. Alternatively, you can use the web-based editor, which offers cloud storage of your programs so you can access them from multiple computers. If you have a Chromebook, see the Arduino Chrome App page for instructions.

In addition to materials in the DIY Mini Drone Kit, you will need:

Prep Work

  1. If you do not know how to use a breadboard, refer to our Breadboard Tutorial before you continue.
  2. If you have never used an Arduino before, refer to our How to Use an Arduino guide.
  3. Follow the instructions in the DIY Mini Drone activity to build your drone, with the following important changes:
    1. Do not connect all four motors' negative wires (the black and blue wires) to each other. Each of these wires should have its own longer wire connected to it. This gives your drone a total of five external wires: four individual negative wires, and one positive wire, which is connected to all the motors' positive wires (the red and white wires). See the diagram. The motors are numbered 1–4, going counterclockwise from the top.
    2. You do not need to build a vertical guide pole for your drone for this project. See the next section.

    Diagram showing all four motors' positive wires connected to one positive wire, and each motor with its own individual negative wire

Instructions

Note: if at any point you have trouble getting your drone to work, see the drone project FAQ.
  1. Disassemble four identical retractable pens and remove the springs. You can usually do this by unscrewing part of one end of the pen, and removing the inner parts.

    A disassembled retractable pen, revealing the spring inside
  2. Hot-glue the springs to the bottom of your drone. The springs should be equally spaced around the center of the drone, where the popsicle sticks intersect.
  3. Glue the springs to the center of a piece of cardboard, such that the drone rests on the springs. If needed, shorten the straws on the drone so there is at least 1 cm of space between the straws and the ground.

    Drone mounted on four springs that are glued to a piece of cardboard
  4. Orient the breadboard so it is facing you with the writing upright. Then connect all of the following, as shown in the breadboard diagram (click for a bigger version of the diagram). If you know how to read a circuit schematic, you can use that instead. This circuit has a lot of parts! Work slowly and carefully check your wiring.
    1. Arduino 5V pin to left-side breadboard positive bus.
    2. Arduino GND pin to breadboard ground bus.
    3. Breadboard left ground bus to breadboard right ground bus.
    4. Do not connect the breadboard's left positive bus to the right positive bus. You will use these buses for two different voltage levels (5 V from the Arduino and 6 V from the battery pack). Connecting them will cause a short circuit.
    5. Put four MOSFETs in the breadboard at the following locations, with the writing on their fronts facing to your right:
      1. H1, H2, H3
      2. A5, A6, A7
      3. H9, H10, H11
      4. A13, A14, A15
    6. Put four push buttons in the breadboard, with their pins straddling the middle gap, in the following rows:
      1. 16 and 18
      2. 20 and 22
      3. 24 and 26
      4. 28 and 30
    7. Use jumper wires to make the following connections to the Arduino:
      1. Arduino pin 2 to hole A28
      2. Arduino pin 3 to hole A24
      3. Arduino pin 4 to hole A20
      4. Arduino pin 5 to hole A16
      5. Arduino pin 6 to hole I3
      6. Arduino pin 9 to hole I11
      7. Arduino pin 10 to hole B15
      8. Arduino pin 11 to hole B7
    8. Use jumper wires to connect all of the following breadboard holes to the ground bus:
      1. C5
      2. B13
      3. J1
      4. J9
      5. J18
      6. J22
      7. J26
      8. J30
    9. Connect the motors' negative wires to the following holes:
      1. Motor 1 to B6
      2. Motor 2 to D14
      3. Motor 3 to J10
      4. Motor 4 to J2
    10. Connect the shared motor positive wire to the right-side positive bus.
    11. Finally, connect the battery pack:
      1. Black lead to the ground bus
      2. Red lead to the right-side positive bus
    Breadboard diagram for Arduino drone steering
    Circuit diagram showing four push buttons connected to Arduino pins 2, 3, 4, and 5, and four MOSFETs connected to Arduino pins 6, 9, 10, and 11 to drive the motors from a 6V power source
  5. Upload the code to your Arduino.
    1. Download drone-steering-4-buttons.ino to your computer. If you have some computer programming experience, you can look through the code and read the comments to understand how it works.
    2. Connect the Arduino to your computer with the USB cable.
    3. Open drone-steering-4-buttons.ino in the Arduino IDE.
    4. Press the "Upload" button to send the code to your Arduino.
  6. Test your drone. One at a time, press and hold down each one of the buttons.
    Think about:
    What does the drone do when you hold each button down?
    Think about:
    What happens if you change the values of the defaultSpeed or speedChange variables in the code? Note: Make sure that the sum of these two values added together does not exceed 255, or the value will "overflow" (wrap back around to zero).
  7. Troubleshooting:
    1. If your drone's motors do not spin at all, double-check all of your breadboard wiring. A single misplaced wire can prevent the entire circuit from working.
    2. To confirm that your drone is working, temporarily connect the positive wire to the breadboard's positive bus, and all four negative wires to the breadboard's ground bus. This should make all four motors spin.
    3. Make sure all your wires are connected to the correct Arduino pins. The code does not "know" which pins you have plugged the wires into. You need to plug wires into the pins that are used in the code. If some of your buttons work but others do not, you might have connected wires to the wrong pins.
    The completed setup with the drone connected to the Arduino.

Cleanup

When you are done, power off your Arduino by disconnecting the USB cable, and disconnect the 4xAA battery pack from the circuit.

What Happened?

When you run the code, at first the Arduino makes all four motors spin at the same speed. When you push one of the buttons, the program makes two adjacent motors speed up, and the two opposite motors slow down. The motors that spin faster generate more lift (the force that pushes the drone up). The motors that spin slower generate less lift. This creates uneven forces on opposite sides of the drone (also called a torque), making it tilt in one direction. Each button is programmed to make the drone tilt in a different direction.

Digging Deeper

In this project, you programmed your drone's steering behavior to respond to four buttons. You could make the drone tilt forward, backward, left, or right. However, you could not control the amount of tilt or the direction of tilt with much precision. Real drone controllers use analog joysticks that allow more continuous variation in the controls, allowing you to steer the drone in any direction and control how fast it moves.

Real drones also contain an on-board electronic sensor called an accelerometer. The accelerometer measures the drone's angle of tilt. An on-board computer automatically makes small adjustments to the motors' speed to keep the drone level. This way, the human operator can concentrate on higher-level tasks, like using the drone for aerial photography, without constantly having to worry about keeping the drone balanced.

You can learn how the example code for this project works by reading the detailed comments in the code.

icon scientific method

Ask an Expert

Curious about the science? Post your question for our scientists.

For Further Exploration

  • Can you modify your program to make the drone steer in the yaw direction (rotate about a vertical axis through the center of the drone)?
  • Can you modify your code so you can push four buttons at once, allowing you to tilt the drone in more directions?
  • Can you replace the button controls in your circuit with an analog joystick?

Activities

STEM Activity
1
2
3
4
5
37 reviews
Quadcopters, also called drones, are a fun and popular toy. Explore the world of drones as you build your own mini drone using popsicle sticks in this fun activity. See this page for a complete list of our mini drone projects. You may wish to do the projects in order. Read more
STEM Activity
1
2
3
4
5
11 reviews
How do you make a drone fly up and down? In this activity, you will build a simple circuit to control the altitude of a popsicle stick drone. See this page for a complete list of our mini drone projects. You may wish to do the projects in order. Read more
STEM Activity
1
2
3
4
5
9 reviews
How do drones automatically hover at a constant distance from the ground? Find out in this fun drone project as you build an altitude control circuit for a popsicle stick drone using an ultrasonic distance sensor and an Arduino™. See this page for a complete list of our mini drone projects. You may wish to do the projects in order. Read more
STEM Activity
1
2
3
4
5
2 reviews
How do you steer a drone using a controller with a joystick? Find out in this activity as you program an Arduino to interface with an analog joystick, similar to those found in most video game controllers. You can use the joystick to make a mini popsicle stick drone tilt side to side or move up and down. See this page for a complete list of our mini drone projects. You may wish to do the projects in order. Read more
STEM Activity
1
2
3
4
5
4 reviews
How do drones automatically balance themselves when you let go of the controls? Find out in this project as you build and program an experimental setup to make a drone automatically control its tilt angle about a single axis. See this page for a complete list of our mini drone projects. You may wish to do the projects in order. Read more
STEM Activity
1
2
3
4
5
1 review
Most modern smartphones and video game controllers have a built-in accelerometer used for motion control. In this project you will program an Arduino® to use an accelerometer to control the steering of a miniature popsicle stick drone. See this page for a complete list of our mini drone projects. You may wish to do the projects in order. Read more
STEM Activity
Make your mini popsicle stick drone lift off in this activity! You will build a dual-joystick controller to steer your drone so you can fly it manually. How well can you fly without any help from automatic controls? See this page for a complete list of our mini drone projects. You may wish to do the projects in order. Read more

Careers

Career Profile
Are you interested in developing cool video game software for computers? Would you like to learn how to make software run faster and more reliably on different kinds of computers and operating systems? Do you like to apply your computer science skills to solve problems? If so, then you might be interested in the career of a computer software engineer. Read more
Career Profile
Pilots fly airplanes, helicopters, and other aircraft to accomplish a variety of tasks. While the primary job of most pilots is to fly people and cargo from place to place, 20 percent of all pilots have more specialized jobs, like dropping fire retardant, seeds, or pesticides from the air, or helping law enforcement rescue and transport accident victims, and capture criminals. Pilots enjoy working and helping people in the "third dimension." 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
Career Profile
Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more
Top
Free science fair projects.