PCBWAY PCB Manufacturing

PCBWAY Christas PCB Manufacturing

Advanced PCB Manufacturing
Advanced PCB Manufacturing


Gearbest Tronxy X8 220 x 220 x 200mm Desktop DIY 3D Printer
Tronxy X8 220 x 220 x 200mm Desktop DIY 3D Printer only $139.99

Gearbest Hubsan H117S Zino GPS 5.8G 1KM FPV with 4K UHD Camera 3-Axis Gimbal RC Drone - RTF
Hubsan H117S Zino GPS 5.8G 1KM FPV with 4K UHD Camera 3-Axis Gimbal RC Drone - RTF only $394.99

Gearbest 37-in-1 Sensor Modules Kit
37-in-1 Sensor Modules Kit only $13.99

Arduino Drone V2.0

This tutorial is divided in a few parts:
3d printed drone arduino STL
Drone construction
arduino drone PID
Receiver PWM read
arduino PWM drone
IMU + PID control
arduino drone ESC pwm
ESCs PWM write

0.0 Intro

This is the second version of the previous Arduino based DRONE. In that tutorial we've build the transmitter, receiver and flight controller. The problem is that the flight controller code was a platform named MultiWIi. Now I want to create my own code for the flight controller of the Arduino drone and make it compatible with any commercial radio transmitter/receiver that uses PWM signals. Also compatible with any size, ESCs or brushless motors.

To make it more easy, I've divided the tutorial in a few parts. In the first part I want to show you how to read the PWM signal form a commercial radio receiver and transform that data into microseconds values in range from 1000us to 2000us. Next we will read the IMU data, create the PID and finnaly create the interruption that will write the PWM signal to each ESC.

1.0 Drone construction

The drone is 3D printed. The STL files are below ready to download. I’ve used PLA material to print the drone with a 20% infill and 2 perimeters. My Anet E10 printer have done a very good job. You will also need a radio transmitter and PWM receiver. 4 brushless motors. This are 18 mm diameter brushless motors. For a 250 size drone, are perfect. I’ve used 12 ampers electronic speed controllers, one Arduino NANO, the MPU6050 IMU and the AT10 radio controller with the R12DS receiver. You could use any other PWM output radio controller. You also need a LiPo battery, propellers, wires and maybe a switch.

Download the STL files here:

1.1 Part list

If you don't have a drone body, and you will use the 3D files above, I've made a list with all the components that you will need. Go to the link below for the full part list. I've selected the lowest prices for each part. Be aware that the drone that I'm building is a 250 one (250mm diagonal) so the motors are small, LiPo battery as well.

See the full part list here:

1.2 Schematic

Ok, in this project we won't use the NRF24 modules for the radio connection as in the past tutorial. Now we will use a commercial radio transmitter and reeiver. The one that I've used is an AT 10 version 2 from Radiolink. The receiver is the R12DS with PWM output. So the schematic of the drone is the one below. Make all the connections and then we start withthe code.

arduino drone schematic

Ok, now that we have the body let's begin with the code.