-
Notifications
You must be signed in to change notification settings - Fork 234
LINEAR POT SENSOR
Jaume Olivé Petrus edited this page Aug 28, 2017
·
12 revisions
| What | Comments | |
|---|---|---|
| Identifier | LINEAR_POT | |
| Interface | ADC | |
| Provides | val | Potentiometer % value, from |
| 0 to 1. | ||
| Properties | none | |
![]() |
In this example an encoder is attached at GPIO26 (A), GPIO14 (B) and GPIO21 (SW)
s = sensor.attach("REL_ROT_ENCODER", pio.GPIO26, pio.GPIO14, pio.GPIO21)
s:callback(
function(magnitude)
if (magnitude.dir == -1) then
print("ccw, value "..magnitude.val)
elseif (magnitude.dir == 1) then
print("cw, value "..magnitude.val)
end
if (magnitude.sw == 1) then
print("sw on")
elseif (magnitude.sw == 0) then
print("sw off")
end
end
)
