Okay so I am attempting to run AcellStepper on my teensy 3.5 so that I can get higher speeds with increasing microstepping.
In short if I send "1" into the serial my motor should move x amount of steps.
I am running into a problem whenever I try to send serial commands, after I send a command into the serial it waits a few seconds and spits out a few boxes. There shouldn't be any serial prints just reads so I am confused why it does this. Any thoughts?
Code:
const int stepsPerRevolution = 200*16; // change this to fit the number of steps per revolution
#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(AccelStepper::DRIVER, 9, 8);
//number of steps to each position from 0
//long pos1 = 11810L*8;
//long maxspeed = 3937L*8;
//long accel = 4000L*8;
long pos1 = 23620;
long maxspeed = 7874;
long accel = 8000;
int pos2 = 0;
int pos3 = 9600;
int pos4 = 12800;
int pos5 = 16000;
int pos6 = 19200;
void setup() {
Serial.begin(9600);
}
void loop() {
stepper.setMaxSpeed(maxspeed);
stepper.setAcceleration(accel);
char c;
if(Serial.available()) {
c = Serial.read();
if (c == '1') { // position 1
stepper.moveTo(pos1);
}
if (c == '2') {
stepper.moveTo(pos2);
}
if (c == '3'){
stepper.moveTo(pos3);
}
if (c == '4'){
stepper.moveTo(pos4);
}
if (c == '5'){
stepper.moveTo(pos5);
}
if (c == '6'){
stepper.moveTo(pos6);
}
}
stepper.run();
}
In short if I send "1" into the serial my motor should move x amount of steps.
I am running into a problem whenever I try to send serial commands, after I send a command into the serial it waits a few seconds and spits out a few boxes. There shouldn't be any serial prints just reads so I am confused why it does this. Any thoughts?