Skip to content

AnalogInput.h

Brandon W. Kipp edited this page Feb 13, 2020 · 1 revision

This library is primarily a tool used to stop the constant output of Analog Input sensors. It achieves this by averaging int averagerSampleRate number of samples, using the Average.h library.

To setup a new AnalogInput, you'll need to pass in four parameters:

  1. int pin, location of the input pin
  2. boolean enableAverager, to enable averaging via Averager.h
  3. int, the number of samples to average
  4. boolean enableLowPass, to enable lowpass filtering via Averager.h
  5. void (*callback)(int), a callback function that accepts the returned int value of the sensor

AnalogInput Example

#include "Libraries/AnalogInput.h"

AnalogInput analogInput1;
int analogInput1Pin = A0;

void setup() {

  analogInput1.setup(analogInput1Pin, enableAverager, averagerSampleRate, enableLowPass, [](int analogInputValue) {
    // Do something with analogInputValue
  });

}

void loop() {
  analogInput1.update();
}

Clone this wiki locally