Good morning
First of all ty for your hard work....
I would like to say that I am completely new in the Arduino world and that the know-how in the electrotechnical field is just as limited....
I'm a Drones enthusiast and looking on Youtube I found some tutorials on how to use Arduino to test the functionality of the coupling: esc - brushles motors using the pwm output of arduino and a potentiometer connected to the analog pin.
(basically the equivalent of the potentiometer experiment that controls a led).
Now because I'm as curious as a monkey and I want to learn and not use the copy paste im writing to you for have an help...
The scheme of operation is similar as said to the one led potentiometer and in particular:
Connect the Potentiometer to an analog pin es A0
The motor connects to the esc and the esc is connects to a pwm pin e.g. 9.
after which you map the analog signal to feed the esc to run the engine.
The difference with the led is that in the code that o have found they use the library
servo.write(....)
the sketch type is this:
servo myservos; //but what a fantasy
int val, p;
void setup ()
myservo.attach(9);
void loop
p = analogRead(A0);
val = map(p, 0, 1023, 1000, 2000);
myservo.write(val);
delay(20);
What I don't like, and what I'd like someone to explain to me, is:
-
the map function :
on the digital output does not allow values only from 1 to 255 (as for the led?) having put a scale from 1000 to 2000 does not affect the operation? or the values 1000 and 2000 are to be considered as a scale of possible values from 1 to 255 ?? ie the 256 possible values are then divided into small multiples and increase the potentiomentro then causes a really low increase in the engine??? Roll: -
the function myservo.write() should have a syntax like Syntax
servo.write(angle) where angle: the value to write to the servo, from 0 to 180
so giving it a value between 1,000 and 2,000 makes sense?
I assume that: for the esc (which is different from a servo) the value is not an angle but precisely the value pwm to increase the speed of rotation?
But where is this documented??????
The only answers that i can think is that this code are wrong and the function to use is not servo.write but servo.writemicsoseconds...
So for me the right code must be:
servo myservos;
int val, p;
void setup ()
myservo.attach(9);
void loop
p = analogRead(A0);
val = map(p, 0, 1023, 1000, 2000);
myservo.writeMicroseconds(val);
delay(20);
Ty for any who want help me and sorry for disturb