InputEvents v1.4.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

  1. Thomas Fredericks' Bounce2 library to debounce buttons and switches. Since v1.4.0, debouncing is now built in but you can use your own debouncer via the setDebouncer() method on EventButton,
  2. The EncoderAdapter library to allow the use of almost any underlying encoder class.

EncoderAdapter should be installed automatically by the Library Manager(s).

By default the EncoderAdapter supports Paul Stoffregen's Encoder library - this will need to be installed in order to use encoders or encoder buttons.