Autonomous t200 Thruster

We are currently trying to create a code allowing the arduino to go down for a certain amount of time run for a certain amount of time then repeat a few times. I copied and pasted the code so far below. If you have any suggestions I am all ears. I am currently able to display the pressure and the time on the monitor but the turbine is not running.

//To Do: Sensor Pin Constants
/* pin for turbine*/
#include <Servo.h>

byte servoPin = 9;
Servo servo;
/* Sensors */
const byte Clock = A4; //RV 3028 Clock using later when i learn it
const byte PressureSensor = A2; // Pressure sensor
// To Do: Variables for Timed Events

const unsigned long eventTime_1_Pressure = 5000; // interval in ms
const unsigned long eventTime_2_turbine = 10000; // interval in ms

unsigned long previousTime_1 = 0;
unsigned long previousTime_2 = 0;


void setup(){
  
// To Do: Serial communication
Serial.begin(9600);
servo.attach(servoPin);

  servo.writeMicroseconds(1500); // send "stop" signal to ESC.

   // delay to allow the ESC to recognize the stopped signal


}

void loop(){
/*shoing pressure*/
/* Updates frequently */
unsigned long currentTime = millis();//RV 3028
/* This is event 1 stuff *//*showing pressure*/
if( currentTime - previousTime_1 >= eventTime_1_Pressure ){
  Serial.print ("Pressure: ");
  Serial.println( analogRead(PressureSensor) ); /* displays the pressure*/
 Serial.print ("Time: ");
  Serial.println( millis());
  /* Update the timing for the next event */
  previousTime_1 = currentTime;
  
}

// To Do: Event 2 timing turning on motor
/* Updates frequently */

/* This is event 2 stuff */
if( currentTime - previousTime_2 >= eventTime_2_turbine ){
  Serial.print ("Starting Turbine Speed Event 1: 1300 ");
  

{ 
   unsigned long starttime = millis();
 unsigned long endtime = 3000;
endtime = starttime;
 while ((endtime - starttime) <=3000) // do this for 3 seconds
int signal = 1700; // Set signal value, which should be between 1100 and 1900

  servo.writeMicroseconds(signal); // Send signal to ESC.
}
int signal = 1500; // Set signal value, this stops motor

  servo.writeMicroseconds(signal); // Send signal to ESC.
}
}
 previousTime_2 = currentTime;
}

Hi @Andrew_King, welcome to the forum :slight_smile:

I’ve converted your code to a code block (you can read more about that in the Formatting a Post/Comment section of the How to Use the Forums post), but it seems like the indentation is quite inconsistent, which makes it challenging to follow the code.

From my initial glance, you’ve got a comment in your setup function about a “delay to allow the ESC to recognize the stopped signal”, which I assume is from our BasicESC example code for Arduino, but you’ve seemingly included only the comment, and not the actual delay call.

From the Learn tab of the BasicESC product page,

If you’re not hearing the initial three beeps when power is connected then the thruster isn’t connected properly, and if you’re not hearing the next two beeps then you’re not sending a ‘stopped’ signal properly/for long enough.