-
Notifications
You must be signed in to change notification settings - Fork 0
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:
-
intpin, location of the input pin -
booleanenableAverager, to enable averaging viaAverager.h -
int, the number of samples to average -
booleanenableLowPass, to enable lowpass filtering viaAverager.h -
void (*callback)(int), a callback function that accepts the returnedintvalue of the sensor
#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();
}