Skip to content

alizaliz/EasingCurves

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EasingCurves

Easing library for Arduino. Wrapper and implementation of Robert Penners easeing functions : http://robertpenner.com/easing/

Use this library add vibrance to animations - LED fade, servo movements etc...

BASIC EXAMPLE

/* 
 DESCRIPTION
 ====================
 Fade LED with sine easing curve.
 */
#include <EasingCurves.h>

#define LED_PIN LED_BUILTIN

// Instantiate an EasingCurves object
EasingCurves ease = EasingCurves(SINE_IN, 0, 254, 5000);

bool forward = true;

void setup()
{
  //Setup the LED :
  pinMode(LED_PIN, OUTPUT);
  ease.start();
}

void loop()
{
  switch (ease.currentState())
  {
    case ACTIVE: // Animate while active
      int level;
      if (forward)
      {
        level = ease.getValue(); // Forward on curve
      }
      else
      {
        level = ease.getValueOneMinus(); // Backward on curve
      }
      analogWrite(LED_PIN, level); 
      break;
    case INACTIVE: // Restart and flip direction
      ease.restart();
      forward = !forward;
      break;
  }
}

About

Easing library for Arduino

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages