InputEvents v1.6.0
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
InputEvents Library

An easy to use but comprehensive Arduino Event Library for both physical and logical Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches. Tested on Arduino, ESP and Teensy.

Since v1.4.0 can be used with virtual pins (eg for GPIO extenders) as well as regular GPIO pins.

Picture of button, encoder, potentiometer, joystick and switch

Input Classes

There is one class for each type of physical input. All classes are derived from EventInputBase so share common methods for handling enable/disable, event blocking, timeout and user ID/values.

  • EventButton - used with monentary switches or inputs, usually refered to as 'buttons'.
  • EventEncoder - used for plain encoders such as an MPG or motor encoder. If you use this with an encoder button, no button events will be fired!
  • EventEncoderButton - contains an EventEncoder and an EventButton. Certain button events are changed if the encoder is turned while pressed.
  • EventAnalog - generally used for potentiometers but anything that normally connects to an analog pin will suffice. The analog input value is redefined as a limited number of increments or 'slices' so events are fired at specified thresholds rather than 1024 times over the range of the input.
  • EventSwitch - used for plain on/off switches or inputs.
  • EventJoystick - contains two EventAnalog inputs, enabling very easy use of joysticks with 'interesting' resistance values across their range. The joystick will automatically adjust the extent of the analog range, adjusting slices accordingly. Both X and Y axis can be accessed and configured directly if required.

Source Code

The InputEvents Library is available via the Arduino IDE or PlatformIO Library Managers by searching for 'InputEvwents'

Further information, source code, examples, and guides are available in the github repository.

Dependencies

Since v1.6.0, Input Events has no explicit dependencies, however, if you are using EventEncoder or EventEncoderButton directly attached to GPIO pins, by default, you will need to install Paul Stoffregen's Encoder library.

Search for 'Encoder' in the Arduino IDE or in PlatformIO, ensure your platformio.ini file includes the Encoder library dependency:

lib_deps =
paulstoffregen/Encoder@^1.4.4