Jump to main content

Program Drone Steering with an Arduino®

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!

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

In addition to the materials in the DIY Mini Drone activity to build the drone, 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 Getting Started with 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

  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

Reviews


|
Science Buddies |
Was this review helpful?

Top
Free science fair projects.