> For the complete documentation index, see [llms.txt](https://docs.feelix.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.feelix.xyz/downloads/arduino-library-documentation/effect-functions.md).

# Import Feelix Effects

{% hint style="success" %}
Include the [**Feelix Effect Arduino Library**](/downloads/c-library.md#library-for-exported-feelix-effects) to import Feelix effects.&#x20;

The library includes examples for different use cases.
{% endhint %}

## Initialize the Effect

Effect configuration includes:

* **data\_size** – length of the data array.
* **angle** – width of the effect (in degrees or ms).
* **quality** – spacing between data points in the array.
* **control type** – effect type (torque, angle, or velocity).\
  Haptic effects can be dependent or independent (see [**Getting Started**](/getting-started/designing-effects/effects.md)).

```cpp
EffectConfig_s zigzag_spring_config { 
	.data_size = 6,
	.angle = 100,
	.quality = 20,
	.effect_type = Effect_type::INDEPENDENT,
	.control_type = Control_type::TORQUE
 };

float data_zigzag_spring[] = {1.0, 0.4, 0.8, 0.2, 0.6, 0.0};
FeelixEffect zigzag_spring = FeelixEffect(zigzag_spring_config, data_zigzag_spring);
```

```cpp
enum Effect_type {
    INDEPENDENT  = 0, 
    DEPENDENT    = 1,
    NOTSET       = -12345 
};

enum Control_type {
    POSITION        = 3, 
    TORQUE          = 2,
    VELOCITY        = 1,
    VELOCITY_ANGLE  = 4,
    MOVE_TO         = 5,
    UNDEFINED       = -12345   //not yet known or invalid state
};
```

## Play a Haptic Effect

Call `playHapticEffectAtAngle(FeelixEffect effect, float angle_deg)` in every loop to check the torque or angle based on the motor’s current position. Pass the `FeelixEffect` and the effect’s start position (in degrees) as arguments. Multiple effects can run in parallel or alternate using `if` statements.

Call `move_feelix()` to send data to the motor, it automatically sums overlapping effects.

```cpp
feelix.playHapticEffectAtAngle(zigzag_spring, 80.0);
   
feelix.move_feelix();
```

## Play a Velocity Effect

Call `playVelocityEffect(FeelixEffect effect, void (*callback)() = NULL)` in every loop to check the velocity based on the motor’s current speed. The optional callback is executed when the effect finishes.

Call `move_feelix()` to send data to the motor.

```cpp
feelix.playVelocityEffect(velocity_effect);

feelix.move_feelix();
```

## Change Feelix Effect Settings

Effect settings can be adjusted in the setup or main loop at run time.<br>

* **Enable effect** – `effect.enable();` *(enabled by default)*
* **Disable effect** – `effect.disable();`
* **Check if enabled** – `effect.isEnabled();` *(returns true if enabled, false if not)*
* **Start / Stop velocity effect**

  ```cpp
  effect.play(true, feelix.current_time);  //(time can be used for start delay)
  effect.play(false);                      // stop
  ```

  * `play = true` starts the effect
  * `time` can delay the start (default is `millis()`)
  * `play = false` stops the effect
* **Check if velocity effect is playing** - `effect.isPlaying();`  *(returns true if playing, false if not)*
* **Change effect scale**&#x20;

  * `scale.x` controls angle (for position/torque effects) or duration (for velocity effects).
  * `scale.y` controls intensity (%)

  ```cpp
  effect.scale.x = 1.5; // default 1.0 scale from -1.0 to 1.0 
  effect.scale.y = 0.5; // default 1.0 scale from -1.0 to 1.0 
  ```
* **Change vertical position effect**

  * `position.y`&#x20;

  ```cpp
  effect.position.y = -1.0; // default 0.0 scale from -1.0 to 1.0 
  ```
* **Repeat effect** – `effect.infinite = true;` *(default is false, works for both velocity and haptic effects)*
* **Disable effect by direction** *(haptic only)*&#x20;

  ```cpp
  effect.direction.cw = false;  // default true (clockwise)
  effect.direction.ccw = false; // default true (counterclockwise)
  ```
