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
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,12 +23,24 @@ The source files are also heavily commented, so check those out if you want fine
23
23
Here's a basic example:
24
24
25
25
```Arduino
26
+
// include the ResponsiveAnalogRead library
26
27
#include <ResponsiveAnalogRead.h>
27
28
29
+
// define the pin you want to use
28
30
const int ANALOG_PIN = A0;
31
+
32
+
// make a ResponsiveAnalogRead object, pass in the pin, and either true or false depending on if you want sleep enabled
33
+
// enabling sleep will cause values to take less time to stop changing and potentially stop changing more abruptly,
34
+
// where as disabling sleep will cause values to ease into their correct position smoothly
29
35
ResponsiveAnalogRead analog(ANALOG_PIN, true);
30
36
37
+
// the next optional argument is snapMultiplier, which is set to 0.01 by default
38
+
// you can pass it a value from 0 to 1 that controls the amount of easing
39
+
// increase this to lessen the amount of easing (such as 0.1) and make the responsive values more responsive
40
+
// but doing so may cause more noise to seep through if sleep is not enabled
41
+
31
42
void setup() {
43
+
// begin serial so we can see analog read values through the serial monitor
32
44
Serial.begin(9600);
33
45
}
34
46
@@ -50,14 +62,20 @@ void loop() {
50
62
}
51
63
```
52
64
53
-
##Methods for usage
65
+
##Constructor arguments
66
+
67
+
-`pin` - int, the pin to read (e.g. A0)
68
+
-`sleepEnable` - boolean, sets whether sleep is enabled. Defaults to true. Enabling sleep will cause values to take less time to stop changing and potentially stop changing more abruptly, where as disabling sleep will cause values to ease into their correct position smoothly.
69
+
-`snapMultiplier` - float, a value from 0 to 1 that controls the amount of easing. Defaults to 0.01. 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 if sleep is not enabled.
70
+
71
+
##Basic methods
54
72
55
73
-`int getValue() // get the responsive value from last update`
56
74
-`int getRawValue() // get the raw analogRead() value from last update`
57
75
-`bool hasChanged() // returns true if the responsive value has changed during the last update`
58
76
-`void update(); // updates the value by performing an analogRead() and calculating a responsive value based off it`
0 commit comments