InternetButtonEvents (community library)


Name Value
Name InternetButtonEvents
Version 1.0.1
Installs 1173
License MIT
Author dwcares
Download .tar.gz
All Versions 1.0.1, 1.0.0

Provides clean, debounced, button and click events for the Particle Internet Button

Example Build Testing

Device OS Version:

This table is generated from an automated build. Success only indicates that the code compiled successfully.

Library Read Me

This content is provided by the library maintainer and has not been validated or approved.


Provides clean, debounced, button state and click events for the Particle Internet Button.

This library simplifies scenarios around publishing events when buttons have been clicked by offering a set of callback-based button events for the Internet Button. It also debounces button pushes to provide more stable button states, with a configurable clickThreshold.

Particle Internet Button (image removed)

Getting Started

Connect your hardware to your Particle Internet Button, add the InternetButton and InternetButtonEvents library to your project and follow this simple example:

#include <InternetButton.h>
#include "InternetButtonEvents.h"

InternetButton b = InternetButton();
InternetButtonEvents buttonEvents = InternetButtonEvents(b);

void setup() {


void loop() {

void buttonClickedHandler(int buttonNumber) {
Serial.print("Button clicked: ");

See the examples folder for more details.

Button events

  • onButtonOn(callback) - Called when any button is pressed.
  • onButtonOff(callback) - Called when any button is was pressed and released.
  • onButtonClicked(callback) - Called when any button is was clicked (equvalent to onButtonOff).
  • onAllButtonsOn(callback) - Called when all buttons are pressed together.
  • onAllButtonsOff(callback) - Called when all buttons were pressed then one or more buttons was released.
  • onAllButtonsClicked(callback) - Called when all buttons are clicked (equvalent to onAllButtonsClicked).

Button debouncing

InternetButtonEvents debouces button presses to limit accidental clicks. By default, a button needs to be pressed and released for 200 milliseconds for a click to register.

This click threshold can be modified in the constructor for InternetButtonEvents.

int clickThreshold = 300;
InternetButtonEvents buttonEvents = InternetButtonEvents(b, clickThreshold);

You can inspect the debouced button state by using these helpers:

  • buttonOn(int buttonNumber) - Get the debounced state of a specified button.
  • allButtonsOn() - Get the debounced state if all buttons are clicked.


Here's how you can make changes to this library and eventually contribute those changes back.

To get started, clone the library from GitHub to your local machine.

Change the name of the library in to something different. You can add your name at then end.

Modify the sources in and with the new behavior.

To compile an example, use particle compile examples/usage command in Particle CLI or use our Desktop IDE.

After your changes are done you can upload them with particle library upload or Upload command in the IDE. This will create a private (only visible by you) library that you can use in other projects. Do particle library add InternetButtonEvents_myname to add the library to a project on your machine or add the InternetButtonEvents_myname library to a project on the Web IDE or Desktop IDE.

At this point, you can create a GitHub pull request with your changes to the original library.

If you wish to make your library public, use particle library publish or Publish command.


Copyright 2018 @dwcares

Licensed under the MIT license

Browse Library Files