2

First of all sorry that i dont know much about programming, most of my codes are just copy paste. And of course, i know this question has been asked before, but while using this code:

#include <AccelStepper.h>

AccelStepper stepper (1,7,6);

void setup() {
  // put your setup code here, to run once:
 
 stepper.setMaxSpeed(100);
 
 stepper.setAcceleration(20);
 
  stepper.runToNewPosition(100);
 
 delay (1000);
 
stepper.runToNewPosition(0);
 
delay(1000);

}

void loop() {
  // put your main code here, to run repeatedly:

}

The code worked perfectly once but after resetting the power the code doesnt work in a way that my stepper motor just idles. Obviously what I want is for the stepper motor to execute the code once per power on. Is there something that i miss? many thanks!

  • I have never used a stepper motor but check the wiring again and insted of using arduino for programing use platform.io it will help you to understand and complete the code faster it at least helped me a lot – xbox gamer Oct 27 at 19:17
  • run an example code from the arduino IDE just to verify hardware – jsotola Oct 27 at 20:51
  • don't forget that there is no feedback from the motor .... maybe the driver chip is unpowered or it is incorrectly connected or it is defective – jsotola Oct 27 at 20:59
  • For setup() there's no difference between power on and reset. Eventually there are subtle ones (hardware dependent -> reason of reset), but not on the Arduino layer. – DataFiddler Oct 28 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.