6 #ifndef MIN_PULSE_WIDTH
7 #define MIN_PULSE_WIDTH 544
10 #ifndef MAX_PULSE_WIDTH
11 #define MAX_PULSE_WIDTH 2400
14 #ifndef DEFAULT_PULSE_WIDTH
15 #define DEFAULT_PULSE_WIDTH 1500
18 #ifndef REFRESH_INTERVAL
19 #define REFRESH_INTERVAL 20000
24 #define MAX_DEGREES 180l
37 if (pwm!=
nullptr)
delete pwm;
47 this->is_attached =
true;
52 void attach(
int pin,
int min,
int max) {
66 void write(
int value) {
67 int pulse_width_ms = value;
69 pulse_width_ms = map(value,MIN_DEGREES, MAX_DEGREES, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
71 writeMicroseconds(pulse_width_ms);
75 void writeMicroseconds(
int value) {
79 pwm->setDutyCycle(pin, value * 1000);
85 return map(pwm_value, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH, MIN_DEGREES,MAX_DEGREES);
88 int readMicroseconds() {
98 int8_t min = MIN_DEGREES;
99 int8_t max = MAX_DEGREES;
100 bool is_attached =
false;
We provide an alternative Pico implementation for the Servo class which is compatible with the Arduin...
Definition: PicoPWMServo.h:31
void attach(int pin, int min, int max)
as above but also sets min and max values for writes.
Definition: PicoPWMServo.h:52
void attach(int pin)
attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
Definition: PicoPWMServo.h:41