/servo_smooth_move

A python script for Raspberry Pi that moves servo's angle with smoothly using cosine.

Primary LanguagePython

About

A python script for Raspberry Pi that moves servo's angle with smoothly using cosine. That project does not serve a complete module, it just provides an algorithm to inspire.

The Idea

Controlling the servo's acceleration. Starting slowly, then fast, then stop slowly.

Installation

Just download the "servoSmoothMove.py" file and add it to your project.

Key Variables

These are key variables and you can edit according to your needings;

#servo's connected pin.
servoPIN = 15

#movement data.
start_pos = 40
end_pos = 160

The Algorithm

The script uses the cosine function to provide smooth movement. When printing the movement value to the console we get that result and servo's movement will be like that.

                                                                                                                       .
                                                                                                                      .
                                                                                                                    .
                                                                                                                   .
                                                                                                                 .
                                                                                                              .
                                                                                                            .
                                                                                                         .
                                                                                                     .
                                                                                                  .
                                                                                              .
                                                                                          .
                                                                                      .
                                                                                 .
                                                                             .
                                                                        .
                                                                   .
                                                               .
                                                          .
                                                     .
                                                .
                                            .
                                       .
                                   .
                              .
                          .
                      .
                   .
               .
            .
         .
       .
     .
   .
  .
.
.

For Feedback, Question, etc.

You can open an issue, send an email.

Happy coding :)