Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
/ PreciseServo Public archive

Arduino library that extends the functions of the Servo object and allows you to control the speed of each movement 🤖

License

Notifications You must be signed in to change notification settings

kevinmarquesp/PreciseServo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About the project

Precise Servo is an Arduino library that was created to help teachers, students and hobbyists to easily control the speed of servo components, without the need to manually create an for loop to handle that. Pull requests and sugestions are welcome! ❤️

Features:

  • Control the speed of each movement by setting a delay between each degree.
  • Set a minimum and maximum value to not force so much the motor.

⚠ WARNING: if you're in a bigger and complex project that involves handling multiple task at the same time (such as moving a robot and reading the user inputs from the keyboard, as an example) that library maybe break your code, because it uses the delay() function.

📦 Dependencies

⬇️ Download process

  • Go to the releases page and choose a version that you want to use.
  • Download the PreciseServo.zip file.
  • Extract it to your Documents\Arduino\libraries\ directory.
    • Or to your ~/Arduino/libraries/ if you are using a unix system.
  • Then import it to your project and have fun! ☺️

How to use it?

Since that library extends the functions of the actual Servo.h library, every thing that you do with Servo.h can be done with PreciseServo.h at the same way, but with different names.

Start by importing the library and creating your first PreciseServo object:

#include <PreciseServo.h>

// it is just like `Servo my_servo;`
PreciseServo my_servo;

You can normally attach and detach the object from a pin with my_servo.attach() and my_servo.detach(), but one of the killer features of that library is the option to set the minimum and maximum values with the config() method:

void setup()
{
        my_servo.config(7, 20, 140);
}

It will attach the my_servo object to the pin 7 on the board, and set 20° to be the minimum and 140° to be the maximum position. Which means that even if you say it to be 180 degrees, it will stop at 140.

Again, the write() function also works, but to control the speed of each movement you'll need to use the move() function:

void loop()
{
        my_servo.move(140, 10);
}

It will make the motor move to the 140° position, but it will wait 10 milliseconds for each degree.

If it isn't clear enought, the code above is the same thing as:

void loop()
{
        for (int i = 20; i <= 140; i++)
        {
                my_servo.write(i);
                delay(10);
        }
}

Contribution | Project roadmap

Things to be done

  • docs: add a really short and precise description of the AdvancedServo object
  • build: merge this changes to the main branch
  • build: publish a new release with that new AdvancedServo class
  • test: add a proper unit test module for the AdvancedServo object
  • docs: fix README typos

About

Arduino library that extends the functions of the Servo object and allows you to control the speed of each movement 🤖

Resources

License

Stars

Watchers

Forks

Packages

No packages published