Open
Description
The Servo.h header file has this comment for write():
// if value is < 200 it's treated as an angle, otherwise as pulse width in microseconds
This is true for AVR boards:
void Servo::write(int value)
{
if(value < MIN_PULSE_WIDTH)
{ // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
if(value < 0) value = 0;
if(value > 180) value = 180;
value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX());
}
this->writeMicroseconds(value);
}
But the Uno Rev4 implementation seems to only work with angles:
void Servo::write(int angle)
{
if (servoIndex != SERVO_INVALID_INDEX) {
ra_servo_t *servo = &ra_servos[servoIndex];
angle = constrain(angle, 0, 180);
writeMicroseconds(map(angle, 0, 180, servo->period_min, servo->period_max));
}
}
From a quick scan of the different implementations:
- Avr, mbed, megaavr, sam, samd, xmc - Supports angles and microseconds
- nrf52, renesas, stm32f4 - Only works with angles
Should be an easy fix, happy to send a PR if someone will approve it.