I am using Blynk to try and control a 28byj-48 stepper motor using the ULN2003 driver and an Arduino UNO from my iphone via USB withe the iOS Blynk App.
Without using Blynk, my stepper is smooth and works fine:
#include <Servo.h>
#include <Stepper.h>
const int stepsPerMotorRevolution = 32; //No of steps per internal revolution of motor,
const int stepsPerOutputRevolution = 32*64; //no of steps per revolution of the output shaft
const int motorpin1 = 8; //Assign motor pins to Arduino pins
const int motorpin2 = 9; //
const int motorpin3 = 10; //
const int motorpin4 = 11; //
// initialize the stepper library on pins 8 through 11, Motor rev steps, initialise firing sequence 1-3-2-4
Stepper myStepper(stepsPerMotorRevolution, motorpin1,motorpin3,motorpin2,motorpin4);
int pos = 0; // variable to store the servo position
void setup() {
myStepper.setSpeed(600);
}
void loop(){
myStepper.step(-500);
}
But when I use Blynk, the stepper is so jerky and stutters terribly:
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11);
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>
#include <Stepper.h>
const int stepsPerMotorRevolution = 32; //No of steps per internal revolution of motor,4-step mode
const int stepsPerOutputRevolution = 32*64; //no of steps per revolution of the output shaft
const int motorpin1 = 8; //Assign motor pins to board pins
const int motorpin2 = 9; //
const int motorpin3 = 10; //
const int motorpin4 = 11; //
// initialize the stepper library on pins 8 through 11, Motor rev steps, initialise firing sequence 1-3-2-4 blah blah
Stepper myStepper(stepsPerMotorRevolution, motorpin1,motorpin3,motorpin2,motorpin4);
char auth[] = "my auth key here";
void setup(){
SwSerial.begin(9600);
Blynk.begin(auth);
myStepper.setSpeed(600);
}
BLYNK_WRITE(1){
myStepper.step(param.asInt());
}
void loop(){
Blynk.run();
}
I am using a slider on the app to control the stepper by the way. I am not sure what I am doing wrong, any suggestions?