You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-11Lines changed: 7 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,10 @@ ResponsiveAnalogRead is an Arduino library for eliminating noise in analogRead i
8
8
3. Have the option to be responsive when a voltage *stops* changing - when enabled the values returned must stop changing almost immediately after.
9
9
4. The returned values must avoid 'jumping' up several numbers at once, especially when the input signal changes very slowly. It's better to transition smoothly as long as that smooth transition is short.
10
10
11
-
You can preview the way the algorithm works with [sleep enabled](http://codepen.io/dxinteractive/pen/KzGegy) (minimising the time spend transitioning between values) and with [sleep disabled](http://codepen.io/dxinteractive/pen/ezdJxL) (transitioning responsively but smooth).
11
+
You can preview the way the algorithm works with [sleep enabled](http://codepen.io/dxinteractive/pen/zBEbpP) (minimising the time spend transitioning between values) and with [sleep disabled](http://codepen.io/dxinteractive/pen/ezdJxL) (transitioning responsively but smooth).
12
12
13
13
An article discussing the design of the algorithm can be found [here](http://damienclarke.me/code/posts/writing-a-better-noise-reducing-analogread).
14
14
15
-
###Impending version bump
16
-
Written 14/07/2016
17
-
18
-
Improvements to the sleep algorithm will be pushed as a minor version upgrade soon. Special thanks to /u/brontide for the assistance.
19
-
20
15
##How to install
21
16
22
17
In the Arduino IDE, go to Sketch > Include libraries > Manage libraries, and search for ResponsiveAnalogInput.
@@ -38,7 +33,7 @@ const int ANALOG_PIN = A0;
38
33
39
34
// make a ResponsiveAnalogRead object, pass in the pin, and either true or false depending on if you want sleep enabled
40
35
// enabling sleep will cause values to take less time to stop changing and potentially stop changing more abruptly,
41
-
// where as disabling sleep will cause values to ease into their correct position smoothly
36
+
// where as disabling sleep will cause values to ease into their correct position smoothly and with slightly greater accuracy
42
37
ResponsiveAnalogRead analog(ANALOG_PIN, true);
43
38
44
39
// the next optional argument is snapMultiplier, which is set to 0.01 by default
@@ -81,6 +76,8 @@ void loop() {
81
76
-`int getRawValue() // get the raw analogRead() value from last update`
82
77
-`bool hasChanged() // returns true if the responsive value has changed during the last update`
83
78
-`void update(); // updates the value by performing an analogRead() and calculating a responsive value based off it`
79
+
-`void update(int rawValue); // updates the value by accepting a raw value and calculating a responsive value based off it (version 1.1.0+)`
80
+
-`bool isSleeping() // returns true if the algorithm is in sleep mode (version 1.1.0+)`
84
81
85
82
##Other methods (settings)
86
83
@@ -98,9 +95,8 @@ Sleep allows you to minimise the amount of responsive value changes over time. I
98
95
99
96
It's behaviour can be modified with the following methods:
100
97
-`void enableEdgeSnap() // edge snap ensures that values at the edges of the spectrum (0 and 1023) can be easily reached when sleep is enabled`
101
-
-`void setSleepDelay(unsigned int ms) // sets the amount of time before sleeping`
102
-
-`void setSleepActivityThreshold(unsigned int newThreshold) // the amount of movement that must take place while asleep for it to register as activity and start moving the output value. Defaults to 20.`
103
-
-`void setAwakeActivityThreshold(unsigned int newThreshold) // the amount of movement that must take place while awake for it to register as activity, and reset the timer before sleep occurs. Defaults to 5.`
98
+
-`void setSleepDelay(int ms) // sets the amount of time before sleeping`
99
+
-`void setActivityThreshold(float newThreshold) // the amount of movement that must take place for it to register as activity and start moving the output value. Defaults to 4.0. (version 1.1+)`
104
100
105
101
###Snap multiplier
106
102
@@ -109,7 +105,7 @@ It's behaviour can be modified with the following methods:
109
105
SnapMultiplier is a value from 0 to 1 that controls the amount of easing. Increase this to lessen the amount of easing (such as 0.1) and make the responsive values more responsive, but doing so may cause more noise to seep through when sleep is not enabled.
110
106
111
107
###Analog resolution
112
-
-`void setAnalogResolution(unsigned int resolution)`
108
+
-`void setAnalogResolution(int resolution)`
113
109
114
110
If your ADC is something other than 10bit (1024), set that using this.
0 commit comments