Control a motor with ESC and millis() - remote control

Agree. Exactly, more work, more risks.... and very tiresome to verify!......

As we don't use the variable previousMillis in the code, can I delete it?

Yes. There are probably some more variables not used but be careful if You want to run the hoover across the code.... Very easy to run into trouble. I suggest skipping that clean up.

It might come up handy in the future.... Joking!

:nerd_face:

It was great working with you on this code. Thank you again!

Thank You for Your responsive acting. Being an old helpdesk guy I can guide You to do a lot but 100% discipline is needed, do exactly as adviced and nothing else.
What do You think about directing a house wife to open the blue doors of a large computer, use a bread knife inside there, swap connectors.....? It worked that time!

Hi Railroader,
I hope you're doing good an remember me! :slight_smile:

I wondered how I can increase the microseconds at lowRPM() mode by 10 every minute, when the button for lowRPM() was pressed for the first time.

And the microseconds at maxRPM() mode by 2 every minute, when the button for maxRPM() was pressed for the first time.

Do you have an idea eventually?
Can I do it like this? :

rpmtime=millis();
 if(rpmtime == millis() + 60000L){
rpm = rpm+10;
servo.writeMicroseconds(rpm);
}

The code is the same below:

#include <RCSwitch.h>
#include <Servo.h>
Servo servo;
RCSwitch mySwitch = RCSwitch();

unsigned long previousMillis = 0;
const long interval = 5000;
int mode;
unsigned long button3timer;
unsigned long button3inhibit;

void setup()
{
  Serial.begin(115200);
  mySwitch.enableReceive(0);  // Empfänger ist an Interrupt-Pin "0" - Das ist am NANO der Pin2
  servo.attach(3, 1000, 2000);

}

void loop() {


  if (mySwitch.available())
  {
    Serial.print("character/value avaiblabe ");
    Serial.println(millis());

    int value = mySwitch.getReceivedValue();
    mySwitch.resetAvailable();

    Serial.print("Integer read ");
    Serial.println(millis());

    if (value == 5680)
    {
      mode = 1;
      zero ();
    }

    else  if (value == 5679)
    {
      mode = 2;
      lowRPM ();
    }

    else  if (value == 5678)
    {
      if ( millis() > button3inhibit)
      {
        mode = 3;
        maxRPM();
        button3timer = millis();
        button3inhibit = millis() + 60000L;//No retrigger within 60 seconds.
      }
      else {
        // Do nothing until inhit time is over.
      }
    }
  }

  if ((mode == 3) && ((button3timer + interval) < millis()))
  { //interval expired. change to mode 2
    mode = 2;
    lowRPM();
  }

}
void lowRPM () {
  servo.writeMicroseconds(1800);
  //  mySwitch.resetAvailable();
}

void zero () {
  servo.writeMicroseconds(1500);
  //  mySwitch.resetAvailable();
}

void maxRPM () {
  servo.writeMicroseconds(2000);
  //  mySwitch.resetAvailable();
}

Hi LarryD,
do you have time to help me with the time depending increase of write (microseconds) in my code?
I wondered how I can implement it into my code (see above).
Unfortunately I don't have a solution by now.