Good day
I am currently working on a project involving several different sensors and three motors, two DC and one Stepper.
I made a topic last week (Stepper motor -Problem) where the problem was I did not use the appropriate stepper motor controller.
I got myself Pololu A4988 - Black Edition and tested the following code, which writes to the LCD and turns the motor:
#include <AccelStepper.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#define STEP_PIN 46
#define DIR_PIN 48
AccelStepper stepper(1, STEP_PIN, DIR_PIN);
void setup()
{
stepper.setMaxSpeed(2000);
stepper.setSpeed(-1000);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("MOTOR TESTING");
}
void loop()
{
stepper.runSpeed();
}
The motor worked perfectly as can be seen in this VIDEO
Now I want to be able to update the LCD screen and display sensor readings and therefore I put the LCD commands in the void loop just to test the screen. See following code:
#include <AccelStepper.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#define STEP_PIN 46
#define DIR_PIN 48
AccelStepper stepper(1, STEP_PIN, DIR_PIN);
void setup()
{
stepper.setMaxSpeed(2000);
stepper.setSpeed(-1000);
lcd.begin(16,2);
}
void loop()
{
stepper.runSpeed();
lcd.setCursor(0,0);
lcd.print("MOTOR TESTING");
}
After I ran the program the motor was acting strange. See this VIDEO
So bottom line is: Whenever there are some other commands with stepper.runSpeed() in the void loop (like sensor readings, LCD displaying, DC motors turning) the motor does not fully function. Its like there is some disturbance in the signal from the arduino to the motor.
Hopefully someone can help!