#include "simple.h"
#include <BlenderServoAnimation.h>
#include <Servo.h>
// Frames per second - see original Blender animation / simple.h
#define FPS 25
// Total animation frames - see original Blender animation / simple.h
#define FRAMES 200
// Arduino Servo object to send positions
#define SERVO_COUNT 2
Servo servo[SERVO_COUNT];
byte servo_pins[SERVO_COUNT] = {4, 5};
// Callback function which is called whenever a servo needs to be moved
void move(byte servoID, int angle) {
servo[servoID].write(angle);
}
// Animation object to represent the original Blender animation
BlenderServoAnimation::Animation animation(FPS, FRAMES);
// Servo object to manage the positions
BlenderServoAnimation::Servo myBlenderServo0(0, Lower, move);
BlenderServoAnimation::Servo myBlenderServo1(1, Upper, move);
void setup() {
for(int n = 0; n < SERVO_COUNT; n++)
{
servo[n].attach(servo_pins[n]);
}
// Add the Blender servo object to the animation
animation.addServo(myBlenderServo0);
animation.addServo(myBlenderServo1);
// Trigger the animation loop mode
animation.loop();
}
void loop() {
// Update the animation state on each loop
animation.run();
}