Hi,
I'm controlling a servo using the ServoEaser library (GitHub - todbot/ServoEaser: Arduino library for servo easing)
What the code does it, when pressing a button a servo makes a list of moves and stops until the next time the button pressed
the servo is connected to a ATX power supply which controlled by arduino (simple like turning on led)
What i'm trying to do is to add power on before the servo moves and power off after the servo moves
power on > servo moves > power off (until the button will be pressed another time)
However i tried few methods and no one of them works...
Does any one have an idea how can i work this out ?
(i was only managed to turn on the ATX before the servo moves by pressing the button)
Thanks !
Maayan
Here's the code:
//
// ServoEaser4ButtonPlay.ino -- trigger a move list with a button
//
// 2011, TeamPneumo, Tod E. Kurt, http://todbot.com/blog/
//
//
#include <Servo.h>
#include "ServoEaser.h"
const int ledPin = 13;
const int servoPin = 8;
const int buttonPin = 7;
const int atx = 53;
int servoFrameMillis = 20; // minimum time between servo updates
Servo servo;
ServoEaser servoEaser;
int myServoMovesCount1 = 8;
// configurable list of servo moves
ServoMove myServoMoves1[] = {
// angle, duration
{25, 1700},
{95, 1700},
{95, 1700},
{21, 1700},
{21, 1700},
{43, 1700},
{43, 1700},
{21, 1700},
};
void setup()
{
pinMode(atx, OUTPUT);
digitalWrite(atx, HIGH); //Power the ATX OFF
pinMode( buttonPin, INPUT_PULLUP); // turn on internal pullup resistor
servo.attach( servoPin );
servoEaser.begin(servo, servoFrameMillis);
}
void loop()
{
servoEaser.update();
// on button press, play moves once
if( digitalRead(buttonPin) == HIGH // button press
&& !servoEaser.isRunning() // to trigger only if not running
) {
digitalWrite(atx, LOW); //Power the ATX ON
delay(2000); //Wait 2 sec
servoEaser.play( myServoMoves1, myServoMovesCount1, 1 ); // do the servo moves
delay(13600);// Wait until the servo list will finish the moves list
digitalWrite(atx, HIGH); //Power the ATX OFF
}
}