Hi Guys/Girls, I am a total noob here and have read and tried to understand what I have done wrong here and cant figure it out, if you are able to hep it is much appreciated.
the code:
#include <AccelStepper.h>
int ButtonA;
AccelStepper stepper(1, 9, 10); //pin 9step, pin10 direction
int pos = 360;
int ButtonAState = 0;
void setup()
{
pinMode(4,INPUT);
//pinMode(5,INPUT);
pinMode(10, OUTPUT); //10 is direction
pinMode(9, OUTPUT); //9 is step
stepper.setMaxSpeed(5000);
stepper.setSpeed(50);
stepper.setAcceleration(9000000);
}
void loop(){
val = digitalRead(ButtonA); //Reads state of button
//Check if button is pressed
if (val == HIGH) {
stepper.runToNewPosition(pos);
delay(50);
}
I am trying to make the stepper turn 360 steps each tiem buttonA is pressed.
thanks.