Awesome
<div align = center>LightweightServo
Part of the Arduino library ServoEasing
</div>If you find this library useful, please give it a star.
Small servo library for Arduino
This library is contained in the Arduino SevoEasing library.
- Comparable to Adafruit_TiCoServo library.
- No problems with servo twitching.
- Enables use of NeoPixels, SoftwareSerial, and DmxSimple together with servos in the same Arduino sketch.
- LightweightServo implementation only for pin 9 and 10 of Arduino Uno, Nano etc..
- Only timer1 hardware and no interrupts or other overhead used.
- Provides auto initialization.
- Supports F_CPU of 16, 8, 4, 2, 1 MHz.
- Save up to 600 bytes program size / 40 bytes RAM including auto initialization compared to Arduino Servo library.
- 8 bytes for each call to
write9()
orwrite10()
.
Usage
As simple as this:
#include "LightweightServo.hpp"
void setup() {
// no initialization required for LightweightServo :-)
// or use manual initialization (and compiler macro "DISABLE_SERVO_TIMER_AUTO_INITIALIZE") to save additional 60 bytes program memory
// initLightweightServoPin9();
}
void loop() {
write9(0);
delay(1000);
write9(180);
delay(1000);
}
API
Compile options / macros for this library
To customize the library to different requirements, there are some compile options / macros available.<br/>
Most macros must be defined in your program before the line #include <LightweightServo.hpp>
to take effect.<br/>
Modify them by enabling / disabling them, or change the values if applicable.
Name | Default value | Description |
---|---|---|
DISABLE_SERVO_TIMER_AUTO_INITIALIZE | disabled | Saves up to 60 bytes flash memory. You must then use the init function initLightweightServoPin9And10() or initLightweightServoPin9_10() manually. |