27
27
//
28
28
// Servo - Class for manipulating servo motors connected to Arduino pins.
29
29
//
30
- // attach(pin ) - Attaches a servo motor to an i/o pin.
31
- // attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds
30
+ // attach(pin) - Attaches a servo motor to an i/o pin.
31
+ // attach(pin, min, max) - Attaches to a pin setting min and max values in microseconds
32
32
// default min is 1000, max is 2000
33
33
//
34
34
// write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds)
44
44
45
45
#include < Arduino.h>
46
46
47
- // the following are in us (microseconds)
48
- //
47
+ // The following values are in us (microseconds).
48
+ // Since the defaults can be overwritten in the new attach() member function,
49
+ // they were modified from the Arduino AVR defaults to be in the safe range
50
+ // of publically available specifications. While this implies that many 180°
51
+ // servos do not operate the full 0° to 180° sweep using these, it also prevents
52
+ // unsuspecting damage. For Arduino AVR, the same change is being discussed.
49
53
#define DEFAULT_MIN_PULSE_WIDTH 1000 // uncalibrated default, the shortest duty cycle sent to a servo
50
54
#define DEFAULT_MAX_PULSE_WIDTH 2000 // uncalibrated default, the longest duty cycle sent to a servo
51
55
#define DEFAULT_NEUTRAL_PULSE_WIDTH 1500 // default duty cycle when servo is attached
@@ -64,12 +68,13 @@ class Servo
64
68
Servo ();
65
69
~Servo ();
66
70
// attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure.
71
+ // returns channel number or 0 if failure.
67
72
uint8_t attach (int pin);
68
- // attach the given pin to the next free channel, sets pinMode, min, and max values for writes .
73
+ // attach the given pin to the next free channel, sets pinMode, min, and max values for write() .
69
74
// returns channel number or 0 if failure.
70
75
uint8_t attach (int pin, uint16_t min, uint16_t max);
71
- // attach the given pin to the next free channel, sets pinMode, min, max values for writes ,
72
- // and sets the initial value, the same as write.
76
+ // attach the given pin to the next free channel, sets pinMode, min, and max values for write() ,
77
+ // and sets the initial value, the same as write() .
73
78
// returns channel number or 0 if failure.
74
79
uint8_t attach (int pin, uint16_t min, uint16_t max, int value);
75
80
void detach ();
0 commit comments