I'm trying to test code through my stepper motor through serial communication, but it is not working. I've tried test cases within the Arduino code and it works perfectly, but even when I try a simple ser.write() function in my Raspberry Pi, it won't turn to the specific point, only a very small turn happens.
I'm using the AccelStepper library, and I plugged my NEMA 23 into the Arduino. Here is the code for Python through a Raspberry Pi:
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
theta = 54
ser.write(theta)
And here's the code for my Arduino Mega:
#include <AccelStepper.h>
AccelStepper stepper(1,7,6); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
void setup(){
Serial.begin(9600);
stepper.setMaxSpeed(150);
stepper.setAcceleration(100);
stepper.setCurrentPosition(0);
}
void loop() {
if(Serial.available() > 0){
int theta = SerialparseInt.read();
double theta_to_pulse = theta/1.8;
stepper.runToNewPosition(theta_to_pulse);
//stepper.runToNewPosition(0);
//stepper.run();
}
Is there any advice?

