setDigitalFilter()
Description
Set digital filter function on pin A, B and Z, to filter noise within a specified range.
Note: In the pulse capture mode, this function can only be used prior to the attachInterrupt(), pulseIn() and pulseInNanoseconds() function within the Encoder library.
Syntax
Enc0.setDigitalFilter(val)
Enc1.setDigitalFilter(val)
Enc2.setDigitalFilter(val)
Enc3.setDigitalFilter(val)
Parameters
Enc0、Enc1、Enc2、Enc3
:Corresponding to ENC0, ENC1, ENC2 and ENC3 encoder interfaces.
val
:Variable (unsigned long) to specify the maximum range of the noise to be filtered, in 10 nano-second (ns).
Returns
None
Example
#include <Encoder.h> void setup() { Serial.begin(9600); Enc0.begin(MODE_AB_PHASE); Enc0.setDigitalFilter(20L); // Filter noise below 200 ns } void loop() { Serial.println(Enc0.read()); delay(100); }
See also
The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.