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