Skip to content

3 POSITION TOGGLE SWITCH

Thomas E. Horner edited this page Mar 12, 2019 · 4 revisions

Specification

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

Notes

  • 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.

Code

-- Attach the switch to GPIO26 and GPIO14
s = sensor.attach("3P_TOGGLE_SWITCH", 26, 14)
s:callback(
   function(data)
      print(data.pos)
   end
)

Back to sensor list

Clone this wiki locally