System.on button click for external button

Good Morning.

I was wondering if the below button click handler could work on external buttons. It is working very well on Argon mode button.

 System.on(button_click, systemEventHandler);// Set up button event handler

void systemEventHandler(system_event_t event, int duration, void* )
{
   //button event handler for enrollment
    if(event == button_click) {
        if(isBeaconEnrollModeOn()){
            setBeaconEnrollModeOff();
        
            
        } else {
            setBeaconEnrollModeOn();
            Serial.println("Beacon Enrollment on\n");
          }
    }

}


// Check if enrolling is on
bool isBeaconEnrollModeOn() {
    return (enrollBeacons);
}

// Set enrolling on
void setBeaconEnrollModeOn() {
      enrollBeacons=1;// enrollemnt is on
}

// Set enrolling off
void setBeaconEnrollModeOff() {
  digitalWrite(D7,HIGH);
  enrollBeacons = 0;// enrollment is off
}

I want to be able to use it on my external button if I change “event” and “Button_click”
to LOAD and buttonLOAD (which is my external button)

const int LOAD = D3;
int buttonLOAD;//holds button load value
pinMode(LOAD, INPUT);//output for triggered led

thanks

No, the internal button handler cannot be used for external buttons.

There are many libraries to handle debouncing of external buttons. I often use the Debounce library in the community libraries.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.