Motorcycle Quickshifter programming help - Arduino Nano

I am extremely new to Arduino, what got me interested in it was seeing people using it to control a Quickshifter on a motorcycle.

I have tried a couple code examples that are out there on this subject but I am unable to get them to work for me. I have a very basic understanding of Arduino code however I cannot yet write it from the ground up and need something to work with.

I'm looking for something that can take an input from a momentary switch and trigger a relay for a few milliseconds no matter if the switch is being held down or not. However there either needs to be another delay for a few milliseconds before the system goes back to searching for an input from the switch and restarting the process ready for use again.

The momentary switch will attach to the gear shifter of the motorcycle and engage just a hair before the shift takes place, this then tells the Arduino to trigger the relay for a brief second and will cut ignition to the engine, allowing for engine torque to be stopped to the gear box and allowing the gear change to take place without the use of a clutch or throttle dip.

If someone could help me out or point me in the right direction that would be superb!

I have also looked at this popular forum post and cannot get it to work for me, as when I trigger it, it does not allow for a re-trigger soon after thus not allowing me to change through the gears fast enough.
The code I was following from this forum post:

const int buttonPin = 2;    // the number of the pushbutton pin - COMMUNICATES TO UIN
const int ledPin = 7;      // the number of the LED pin

// Variables will change:
int ledState = HIGH;         // the current state of the output pin
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
int jaPiscou = 0;

// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);

  // set initial LED state
  digitalWrite(ledPin, ledState);

void loop() {
  // read the state of the switch into a local variable:
  int reading = digitalRead(buttonPin);

  // check to see if you just pressed the button
  // (i.e. the input went from LOW to HIGH),  and you've waited
  // long enough since the last press to ignore any noise:

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();

  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

    // only toggle the LED if the new button state is HIGH
    if (buttonState == HIGH && jaPiscou == 0) {

      digitalWrite(ledPin, LOW);   //apaga o led
      delay(0500); //aguarda 1000 ms TIME BIKE IS OFF
      digitalWrite(ledPin, HIGH); //acende o led
      jaPiscou = 1; //Changes the value of the jaPiscou variable to prevent it from entering that if again
    else {
      if (buttonState == LOW) {
        //Leaves the led on:
        digitalWrite(ledPin, HIGH);
        jaPiscou = 0; //When the button is no longer pressed I leave the variable already in the initial condition that is é = 0


  // set the LED:
  digitalWrite(ledPin, ledState);

  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState = reading;

The forum post itself:


I have also looked at this popular forum post and cannot get it to work for me, as when I trigger it, it does not allow for a re-trigger soon after thus not allowing me to change through the gears fast enough.

How did you determine this? Did you quickly try it on your machine? What time do you actually need? Did you find the timing in the program and try changing it?


Seems a waste of time and effort. All motorcycle gearboxes I have ever had anything to do with were constant mesh.

@Paul_KD7HB, I was able to determine this during my tests by using a 5v LED on the output instead of a relay. It would only allow me to trigger the relay output once every couple minutes, where it needs to be once every few seconds.

I don’t have a specific timing as I need to adjust and tailor it through trial and error once it is on the bike.

And I could not find where you adjust the timing in the program, I was able to find where to adjust the time the relay is active for, however not the timing between shifts. If you could highlight where that part is and inform me how to use it correctly that would be super as I spent over three hours with this code trying to find that part.

Thank you for your response!

Also @Bluejets, That is true, however when a motorcycle gear box has no input, you can change through the gears without the clutch, no? Hence why quickly reducing the input torque to the gear box from the engine allows for this same principle. There are plenty examples of this on youtube. It’s how OEM and third party quickshifters work.