-
Notifications
You must be signed in to change notification settings - Fork 234
TILT SWITCH
Jaume Olivé Petrus edited this page Aug 15, 2017
·
6 revisions
| What | Comments | |
|---|---|---|
| Identifier | TILT_SWITCH | |
| Interface | GPIO | |
| Provides | on | 1 = switch active |
| 0 = switch inactive | ||
| Properties | none | |
| Datasheet | ![]() |
In this example a tilt switch is attached to GPIO26. Sensor changes are processed using a callback:
s = sensor.attach("TILT_SWITCH", pio.GPIO26)
s:callback(
function(magnitude)
if (magnitude["on"] == 1) then
print("on")
else
print("off")
end
end
)In this example a tilt switch is attached to GPIO26. Sensor changes are processed using an infinite loop:
s = sensor.attach("TILT_SWITCH", pio.GPIO26)
while true do
if (s:read("on") == 1) then
print("on")
else
print("off")
end
end
