I'm trying to control an idle-air-control valve using "MsTimer.h" and having a serious problem. When I run the stepper sequence I can move the stepper in and out a specified number of steps and it works great. However, when I want to control the pace of the closing steps using the timer, the stepper does move nearly far enough to close the valve.
/*setup for using an arduino motor controller
* this program works as advertised
*/
int inA1 = 12; // ch a
int inA2 = 13; // ch b
int inB1 = 9; // dis a
int inB2 = 8; // dis b
int dTime = 10;
int nSteps;
int startSteps = 15;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(inA1, OUTPUT);
pinMode(inA2, OUTPUT);
pinMode(inB1, OUTPUT);
pinMode(inB2, OUTPUT);
nSteps = 0; //counter for number of steps
//opens an IAC valve
Serial.println("Moving in");
while(nSteps < startSteps) { //moves plunger in
StepOne();
StepFour();
StepThree();
StepTwo();
nSteps ++;
}
StepStop();
Serial.println(nSteps);
nSteps = 0;
delay(1000);
//closes IAC valve using same number of steps
Serial.println("Moving out");
while(nSteps < startSteps) { //moves plunger out
StepOne();
StepTwo();
StepThree();
StepFour();
nSteps ++;
}
StepStop();
Serial.println(nSteps);
}
void loop() {
// put your main code here, to run repeatedly:
}
void StepOne() {
//arduino motor shield stepper code!!!!!