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!


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? :

 if(rpmtime == millis() + 60000L){
rpm = rpm+10;

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()
  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 ");

    int value = mySwitch.getReceivedValue();

    Serial.print("Integer read ");

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

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

    else  if (value == 5678)
      if ( millis() > button3inhibit)
        mode = 3;
        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;

void lowRPM () {
  //  mySwitch.resetAvailable();

void zero () {
  //  mySwitch.resetAvailable();

void maxRPM () {
  //  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.