Skip to content

PUSH SWITCH SENSOR

Jaume Olivé Petrus edited this page Aug 29, 2017 · 7 revisions

Specification

What Comments
Identifier HALL_SWITCH
Interface GPIO
Provides on 1 = switch active
0 = switch inactive
Properties none
Callbacks? yes

Code

-- Attach switch to GPIO26
s = sensor.attach("PUSH_SWITCH", pio.GPIO26)

s:callback(
   function(data)
      if (data.on == 1) then
         print("on")
      elseif (data.on == 0) then
         print("off")
      end
   end
)
Clone this wiki locally