Interfacing Between Arduino and ESC via a Wii Nunchuck

Hi Guys,

I am relatively new to creating projects with arduino embedded in them, in fact this is my first one!
Please excuse me if i say something off, or incorrect!

Currently I am trying to use a wii nunchuck to control an electric longboard. Ideally I would like it so that the “Z” button acts like a trigger. (So the motor will only run if the user is pressing the “Z” button).

The issue I am facing is that in my code (attached) there is a 4 seconds delay when attempting to re-accelerate. Basically, say a user presses the “Z” button and begins to adjust the throttle to the desired speed, but then say they decide to release the “Z” button to slow down. If they wish to re-accelerate now (by re-pressing the “Z” button and adjusting the throttle) they must hold “Z” for atleast 4 seconds with the throttle in the neutral position otherwise nothing will happen.

I hope that makes sense, otherwise I can try to clarify!

I thought my code would make it instantaneous so there would be no delay. Would anyone know why this problem is occurring and how I can fix it?

Any help is appreciated!!!

Thanks!
-H

ESC: https://hobbyking.com/en_us/hobbykingr-tm-x-car-beast-series-esc-1-8-scale-120a.htm

Code:

#include <Servo.h>
#include <Wire.h>
#include "nunchuk.h"


Servo esc;
int motor;

void setup() {
  // put your setup code here, to run once:
  esc.attach(9);
  //esc.writeMicroseconds(1500);
  Serial.begin(19200);
  nunchuck_setpowerpins();
  nunchuck_init();
  Serial.print("Ready\n");
  

}

void loop() {
  // put your main code here, to run repeatedly:


  nunchuck_get_data();                                        //Get data from nunchcuk.

  int joystick_Y = nunchuck_joyy();                           //Variable to store joystick vertical information
  int Button_Z = nunchuck_zbutton();                          //Variable to store "Z" button information
  int Button_C = nunchuck_cbutton();                          //Variable to store "C" button information

    motor = map(joystick_Y, 122,213,1000,2000);               //map the joystick postion to motor speed

if(Button_Z == 1)                                             //Only if the "Z" button is pressesd excute the following code
{
    Serial.print("Pressed\t");                  
  
    esc.writeMicroseconds(motor);                             //output information to the motor
    Serial.print("sensor = ");                                //report information to serial monitor
    Serial.print(joystick_Y);
    Serial.print("\t output = ");
    Serial.println(motor);
}
else if (Button_Z == 0)                                   //If the "Z" button IS NOT pressed excute this code
{
  Serial.print("NOT Pressed\t");
   // motor = map(joystick_Y, 122,213,1000,2000);
    esc.writeMicroseconds(0);                                        //send 0 to the motor
    Serial.print("sensor = ");
    Serial.print(joystick_Y);
    Serial.print("\t output = ");
    Serial.println(motor);
}



  delay(1); 

}