-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the documentation of the library and especially function atta…
…ch() #1
- Loading branch information
1 parent
2dec948
commit 4bb66d8
Showing
5 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
# ESP32-Arduino-Servo-Library | ||
# ESP32-Arduino-Servo-Library [![Build Status](https://travis-ci.org/RoboticsBrno/ESP32-Arduino-Servo-Library.svg?branch=master)](https://travis-ci.org/RoboticsBrno/ESP32-Arduino-Servo-Library) | ||
|
||
Generate RC servo signal on a selected pin. | ||
|
||
Base on [servo library for stm32f4 (d2a4a47)](https://github.com/arduino-libraries/Servo/blob/master/src/stm32f4/ServoTimers.h). | ||
|
||
The same interface as Arduino/Servo: https://www.arduino.cc/en/Reference/Servo | ||
## Interface | ||
|
||
The interface is similar to Arduino/Servo: https://www.arduino.cc/en/Reference/Servo | ||
|
||
But the function `atach()` is different: | ||
|
||
```c | ||
bool attach( | ||
int pin, | ||
int channel = CHANNEL_NOT_ATTACHED, | ||
int minAngle = MIN_ANGLE, | ||
int maxAngle = MAX_ANGLE, | ||
int minPulseWidth = MIN_PULSE_WIDTH, | ||
int maxPulseWidth = MAX_PULSE_WIDTH | ||
); | ||
``` | ||
|
||
More information in [source code documentation](https://github.com/RoboticsBrno/ESP32-Arduino-Servo-Library/blob/master/src/Servo.h#L73). | ||
|
||
Example: [04-SimpleServoAngles](examples/04-SimpleServoAngles/04-SimpleServoAngles.ino) | ||
|
||
## PlatformIO | ||
|
||
Also available through the PlatformIO: http://platformio.org/lib/show/1739/ServoESP32 | ||
This library is also available at the [PlatformIO](https://platformio.org) as [ServoESP32](http://platformio.org/lib/show/1739/ServoESP32). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <Servo.h> | ||
|
||
/* | ||
* Description: | ||
* Example for setting the minimal and maximal angle. | ||
*/ | ||
|
||
static const int servoPin = 4; | ||
|
||
Servo servo1; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
servo1.attach( | ||
servoPin, | ||
Servo::CHANNEL_NOT_ATTACHED, | ||
45, | ||
120 | ||
); | ||
} | ||
|
||
void loop() { | ||
for(int posDegrees = 0; posDegrees <= 180; posDegrees++) { | ||
servo1.write(posDegrees); | ||
Serial.println(posDegrees); | ||
delay(20); | ||
} | ||
|
||
for(int posDegrees = 180; posDegrees >= 0; posDegrees--) { | ||
servo1.write(posDegrees); | ||
Serial.println(posDegrees); | ||
delay(20); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters