I am in the middle of trying to figure out how to code a quadcopter with arduino.
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:
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.
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.
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?
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.