I can't get accelstepper to work on my teensy 4.1.
I'm using a DM556T Driver with a 23HS22-2804S stepper.
It works perfect on ARDUINO MEGA using the same exact wiring
The wiring is as follow:
TEENSY 4.1
DIR+ and PUL+ connected to 5V (VIN)
DIR- to pin 2
PUL- to pin 3
ARDUINO MEGA
DIR+ and PUL+ connected to 5V
DIR- to pin 2
PUL- to pin 3
Here's the code I'm using: (working on MEGA, not working on TEENSY 4.1)
Is it because the Teensy only outputs 3.3V on digital pins vs 5V on Arduino mega? And if so - how can I make it run on the Teensy?
I'm using a DM556T Driver with a 23HS22-2804S stepper.
It works perfect on ARDUINO MEGA using the same exact wiring
The wiring is as follow:
TEENSY 4.1
DIR+ and PUL+ connected to 5V (VIN)
DIR- to pin 2
PUL- to pin 3
ARDUINO MEGA
DIR+ and PUL+ connected to 5V
DIR- to pin 2
PUL- to pin 3
Here's the code I'm using: (working on MEGA, not working on TEENSY 4.1)
Code:
// Include the AccelStepper library:
#include <AccelStepper.h>
// Define stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver:
#define dirPin 2
#define stepPin 3
#define motorInterfaceType 1
// Create a new instance of the AccelStepper class:
AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
void setup() {
// Set the maximum speed and acceleration:
stepper.setMaxSpeed(1000);
stepper.setAcceleration(500);
}
void loop() {
// Set the target position:
stepper.moveTo(8000);
// Run to target position with set speed and acceleration/deceleration:
stepper.runToPosition();
delay(1000);
// Move back to zero:
stepper.moveTo(0);
stepper.runToPosition();
delay(1000);
}
Is it because the Teensy only outputs 3.3V on digital pins vs 5V on Arduino mega? And if so - how can I make it run on the Teensy?