Creating a Simplified Quadcopter with Arduino Uno

Hello!

I am in the middle of trying to figure out how to code a quadcopter with arduino.

My components:

4 esc's, 4 brushless motors, 4 propellers, 6 IR sensors, 3300 mah lithium ion to power motors, 9v to power electronics and arduino, and a frame.

Essentially what I am trying to do is make a quadcopter that can detect an obstacle, and move away from it, without any remote controls or user input.

So ideally, when it turns on, it will see it is within y distance from the ground, lift off until the IR sensor is no longer detecting the ground and then do its best to maintain height. Then if the front sensor sees an object, the front two motors will increase to pull it away from the obstacle, and level off when its no longer being detected. Scale this to all 6 directions from the quadcopter.

The system does not include any sort of remote controls. After a set time I will have it turn itself off. To be clear, its only operating between 80-100 cm off the ground, so it will be an option for me to just grab it and stop it by the frame. Precision matters much less, but I want to be able to demonstrate the concept.

While I have programmed arduino before they were simpler projects, this is my first time dealing with esc's, running multiple motors simultaneously, and programming anything to get off the ground. I have been parsing through quadcopter codes but I get lost in the weeds of the flight controls, PIDs, and various ways to code ESC's. So here are some questions or requests I had for anyone that has more experience than me:

  1. Has anyone seen a DIY that has done something similar before? The hardware has been put together using a DIY for building a quadcopter with Arduino, but the actual code is commercial and not made public and plus is entirely focused an taking user input. So I am trying to parse bits and pieces from different resources together to make my own code but it'd be nice to find a template to follow.

  2. I am a bit confused about the purpose of the ESC's, what is the advantage of using an ESC instead of just connecting the motors directly to the Arduino? I was under the impression they keep the motors at the same speed but the codes I go through don't seem to follow this logic.

  3. Another thing I keep coming across is PID code, is that a bit advanced for my purpose since precision and absolute stability are not a concern, or is that necessary when trying to generate lift at all?

  4. Is there any special trick to running four motors or four motors esc's at once with arduino? I was told Arduino can only send outputs one at a time and in order of the code. There are so many quadcopter arduino's out there that this seems to be wrong. I was assuming it is just in the way its wired, but I obviously haven't gotten to that point. Any heads up before getting there would be awesome.

I'll start with those questions for now because that seems to be where I am stuck. I am at the moment going through various guides and explanation videos for different parts of the system. I figured I'd post here though to get some live input/feedback on the project. I'll keep posting here as I make progress and if I succeed in all of this, I'll probably make a DIY guide with code and all.

An Uno is not a good choice for a quadcopter. Other boards have as much or more functionality in a more lightweight form.

MechanicalFox: what I am trying to do is make a quadcopter that can detect an obstacle, and move away from it, without any remote controls or user input.

In no way does that match your description of a "simplified quadcopter". That is a very complex project.

MechanicalFox: 3. Another thing I keep coming across is PID code, is that a bit advanced for my purpose since precision and absolute stability are not a concern, or is that necessary when trying to generate lift at all?

It's only necessary if you don't want your quadcopter to instantly crash. The way a quadcopter works is that the motors are constantly changing speed to maintain control even in a breeze. It's crucial to do this very precisely to achieve any sort of flight stability.

MechanicalFox: 4. Is there any special trick to running four motors or four motors esc's at once with arduino? I was told Arduino can only send outputs one at a time and in order of the code. There are so many quadcopter arduino's out there that this seems to be wrong. I was assuming it is just in the way its wired, but I obviously haven't gotten to that point. Any heads up before getting there would be awesome.

That would depend on what you mean by "send outputs". You can't change the state of multiple pins at exactly the same time using digitalWrite() but you can change them one after another only microseconds apart, to where you and your motors wouldn't notice the difference from "at once". It is possible to change the state of pins simultaneously, and much more quickly if you don't use digitalWrite() and instead write directly to the registers: https://playground.arduino.cc/Learning/PortManipulation But really if you need to ask this question you're not ready to even start on your quadcopter project. Spend some time blinking LEDs and you'll learn the basics that are crucial to success on a more complex project with much less frustration and expense.

you may look at this Arduino Code :

https://create.arduino.cc/editor/plouc68000/1e164966-3efe-4164-822c-fc21b41a1a18/preview