ArminJo / LightweightServo

Lightweight Servo library for Arduino for 2 Servos at Pin 9 and 10. Needs only timer1, no interrupts or other resources.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Badge License: GPLv3     Badge Version     Badge Commits since latest     Badge Build Status     Badge Hit Counter

Stand With Ukraine

Part of the Arduino library ServoEasing

Button Changelog

If you find this library useful, please give it a star.

🌎 Google Translate

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() or write10().

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);
}

Compile options / macros for this library

To customize the library to different requirements, there are some compile options / macros available.
Most macros must be defined in your program before the line #include <LightweightServo.hpp> to take effect.
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.

About

Lightweight Servo library for Arduino for 2 Servos at Pin 9 and 10. Needs only timer1, no interrupts or other resources.

License:GNU General Public License v3.0


Languages

Language:C++ 76.5%Language:C 23.5%