Arduino connection problems

I have been trying to control my odrive using an arduino mega 2560. The problem that im facing is that the serial text stops at “enabling closed loop control…”, and nothing happens.

I then opened the web GUI and observed in the dashboard that it’s turning on and of rapidly, with the “sucess” and “not calibrated” messages switching between one another. I then went into the code and made the delay in the while inside the setup to be 1 instead of 10, and it got to “Odrive running!”, but the position stays at 0 and the vel as well. When i go to the web GUI it stays fixed at “not calibrated”

I would like some help moving forward because i dont know what may be the problem…

here is the full code:

#include <ODriveUART.h>
#include <SoftwareSerial.h>

HardwareSerial& odrive_serial = Serial1;

ODriveUART odrive(odrive_serial);

void setup() {
odrive_serial.begin(115200);

Serial.begin(115200); // Serial to PC

delay(10);

Serial.println(“Waiting for ODrive…”);
while (odrive.getState() == AXIS_STATE_UNDEFINED) {
delay(100);
}

Serial.println(“found ODrive”);

Serial.print("DC voltage: ");
Serial.println(odrive.getParameterAsFloat(“vbus_voltage”));

Serial.println(“Enabling closed loop control…”);
while (odrive.getState() != AXIS_STATE_CLOSED_LOOP_CONTROL) {
odrive.clearErrors();
odrive.setState(AXIS_STATE_CLOSED_LOOP_CONTROL);
delay(1);
}

Serial.println(“ODrive running!”);
}

void loop() {
float SINE_PERIOD = 2.0f; // Period of the position command sine wave in seconds

float t = 0.001 * millis();

float phase = t * (TWO_PI / SINE_PERIOD);

odrive.setPosition(
sin(phase), // position
cos(phase) * (TWO_PI / SINE_PERIOD) // velocity feedforward (optional)
);

ODriveFeedback feedback = odrive.getFeedback();
Serial.print(“pos:”);
Serial.print(feedback.pos);
Serial.print(", ");
Serial.print(“vel:”);
Serial.print(feedback.vel);
Serial.println();
}