motor test code

/* wallbug motor test code */

#include <Stepper.h>

#define STEPS 200

Stepper stepperLeft (STEPS, 8, 9, 10, 11);
Stepper stepperRight (STEPS, 4, 5, 6, 7);

int previousLeft = 0;
int previousRight = 0;

void setup()
{
stepperLeft.setSpeed(30);
stepperRight.setSpeed(30);
pinMode(13, OUTPUT);
}

void loop()
{

int valLeft = analogRead(0);
int valRight = analogRead(1);
if (valRight >= 512)
{
digitalWrite(13, HIGH);
}
else
{
digitalWrite(13, LOW);
}

stepperLeft.step(valLeft - previousLeft);
previousLeft = valLeft;

stepperRight.step(valRight - previousRight);
previousRight = valRight;

}

Advertisements