This code worked 1 time for my drone. I restarted my programme and could not use it again. I don't know why? And with which command can I get the current rotational speed of the motor?
welcome to the arduino-forum.
Well you wrote a short question to get a quick answer. Trying to speed up getting a solution this way just slows you down. There is no way around describing in detail what ESC you are using by posting a link to where you have bought it or a link to a datasheet.
And describing in detail how everything is connected. A standard ESC does not offer information about the rotational speed of the motor.
You can buy some pretty advanced ESCs which offer that but it is very unlikely that your ESC has this feature.
"drone" sounds like a flying device. If you want to create a flying device with three or four propellers where the propellers are creating all lift and you want to create this from scratch
this is a very long journey. A real looooong journey.
If having a drone is must for you look for a DIY kit that use a ready to use openhardware flight-controller and you will still have weeks to get it up and running because you will need time to tune the parameters of the flight-controller. building all this from scratch is a project for years.
I'm not exxagerating for years.
A vehicle driving on the floor is much much easier.
If it has to be flying use a fixed wing plane of a design where this design of the plane is self-stabilising V-shaped wings.
If your aim is just for having fun flying a drone at low cost buy a used one.
I agree that a pre-built quadcopter or a kit of parts known to get along with each other is a better first quadcopter compared to trying to design your own.
But there has been tremendous progress in flight control software. In the last few years, I’ve not had to tune anything.
While it is true that fanatics will work hard to achieve perfection, most of the time the “stock tune” results in very stable very flyable aircraft.
Good thing, too. Tuning is, well, let’s just say I am happy to no longer need to do.