Hey!
Ive just started a to build a 3d printed car that will use 28byj-48 and Ul2003n drivers. I will eventually use a app for controll.
The issue ive come to in tests is to just keep the motor turning while something is true. Im using the Accelstepper library to be able to move all motors at the same time.
So what im looking for help with is to find a some fuctions or code to make that happen.
#include <AccelStepper.h>
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
// ULN2003 Motor Driver Pins
#define IN1 16
#define IN2 5
#define IN3 4
#define IN4 0
// initialize the stepper library
AccelStepper stepper(AccelStepper::HALF4WIRE, IN1, IN3, IN2, IN4);
void setup() {
// initialize the serial port
Serial.begin(115200);
// set the speed and acceleration
stepper.setMaxSpeed(3000);
stepper.setAcceleration(1000);
// set target position
stepper.moveTo(stepsPerRevolution);
}
void loop() {
if (stepper.distanceToGo() == 10){
stepper.moveTo(2*stepper.currentPosition());
}
// move the stepper motor (one step at a time)
stepper.run();
}
and also this
#include <AccelStepper.h>
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
// ULN2003 Motor Driver Pins
#define IN1 16
#define IN2 5
#define IN3 4
#define IN4 0
// initialize the stepper library
AccelStepper stepper(AccelStepper::HALF4WIRE, IN1, IN3, IN2, IN4);
void setup() {
// initialize the serial port
Serial.begin(115200);
// set the speed and acceleration
stepper.setMaxSpeed(3000);
// set target position
}
void loop() {
stepper.setAcceleration(50);
stepper.setSpeed(2000);
stepper.runSpeed();
}
The main issue with the second part of code is that when its uploaded to the Esp8266 the motor starts to vibrate but now turning. But if i turn the shaft a bit by hand first it starts to spin as normal. There is a bit of resistance when i move it by hand. It is almost like the motor stalls...