forked from whitecatboard/Lua-RTOS-ESP32
-
Notifications
You must be signed in to change notification settings - Fork 0
3 POSITION TOGGLE SWITCH
Thomas E. Horner edited this page Mar 12, 2019
·
4 revisions
What | Comments | |
---|---|---|
Identifier | 3P_TOGGLE_SWITCH | |
Interface | 2 GPIO | |
Provides | pos | 1 = switch in pos 1 (up position) 2 = switch in pos 2 (down position) 0 = switch in pos 0 (mid position) |
Properties | none | |
Callbacks? | yes |
- With this sensor you can get the position of a DPDT (double-pole, double-throw) switch.
- A DPDT has 6 terminals, organised in 2 rows. This sensor only use one row of terminals. Connect the common terminal to GND and each of the other terminals to a GPIO.
- Hardware pull-ups are not required.
- Hardware debouncing are not required.
- When the GPIO level state changes the sensor reads the switch position and a callback is executed reporting the switch position.
-- Attach the switch to GPIO26 and GPIO14
s = sensor.attach("3P_TOGGLE_SWITCH", 26, 14)
s:callback(
function(data)
print(data.pos)
end
)