I am using the Servo library currently, but I want to drive ESCs at 400Hz. Several libraries exist in varying degrees of completion, I could also use the timers myself, but is there something wrong with the following approach:
Looking forward to opinions (I mean facts) and thanks for you help.
Code:
static const int OUT_PIN = 23;
const float LOWER_LIMIT = 3276.8; // 2^16 / 100 * 5 = 5 % duty cycle
const float UPPER_LIMIT = 6553.6; // 2^16 / 100 *10 = 10% duty cycle
int main() {
analogWriteResolution(16);
pinMode(OUT_PIN, OUTPUT);
analogWriteFrequency(OUT_PIN, 400);
while(true) {
for (float value = LOWER_LIMIT; value < UPPER_LIMIT; value += 1) {
analogWrite(OUT_PIN, value);
delay(10);
}
}
}
Looking forward to opinions (I mean facts) and thanks for you help.