Brushless motor coding

Hello world.
i’m trying to control a brushless motor while at the same time measuring its rpm using an effect hall sensor. The code runs fine when controling the motor and the sensor alone, but when i put them together the sensor part works fine but the motor doesn’t seem to receive the information regarding the PWM, thus it does not rotate. I’m almost sure that the problem is on the code’s logic. Can anybody help me with this problem plaese? the code im using is down below, thank you.

ProjetoSpinner.ino (1 KB)

#include <Servo.h>
Servo ServoMotor;
const int hallSensorPin = 2;   // connect the hall effect sensor on pin 2
const unsigned long sampleTime = 1000;
//motor control pin
int pino_motor = 6;
//valor must be between 0 and 179
int valor=50;


void setup() 
{
  Serial.begin(9600); 
  pinMode(hallSensorPin,INPUT);
  ServoMotor.attach(pino_motor); 
  Serial.println("Aguardando 5 segundos....");  
  delay(5000);
  
}

void loop() 
{
  delay(100); 
  ServoMotor.write(valor); 
  int rpm = getRPM();
  Serial.print (rpm);
  Serial.println();
}
 
int getRPM()
{
  int count = 0;
  boolean countFlag = LOW;
  unsigned long currentTime = 0;
  unsigned long startTime = millis();
  while (currentTime <= sampleTime)
  {
    if (digitalRead(hallSensorPin) == HIGH)
    {
      countFlag = HIGH;
    }
    if (digitalRead(hallSensorPin) == LOW && countFlag == HIGH)
    {
      count++;
      countFlag=LOW;
    }
    currentTime = millis() - startTime;
  }
  int countRpm = int(60000/float(sampleTime))*count;
  return countRpm;
}

I'm surprised that you want to run a brushless motor with the library <Servo.h>.
That will not work. A servo goes to given value with Servo.write (value) and stops.
The value is more or less an analogue position specification - but no speed.

What are your misconceptions (or me)?
Servo.h and brushless motor is absolutely not compatible.

RudolfAtRTC:
I'm surprised that you want to run a brushless motor with the library <Servo.h>.
That will not work. A servo goes to given value with Servo.write (value) and stops.
The value is more or less an analogue position specification - but no speed.

What are your misconceptions (or me)?
Servo.h and brushless motor is absolutely not compatible.

This will be an RC BLDC driven by an ESC that accepts standard RC pulse width control as provided by the Servo library.

What I can't see is the arming sequence for the ESC?