grove.grove_tilt_switch

This is the code for

Examples

from grove.grove_tilt_switch import GroveTiltSwitch
import time

# connect to pin 5 (slot D5)
PIN = 5

swicth = GroveTiltSwitch(pin)

def on_trigger():
    print('Triggered')
def on_release():
    print("Released.")

swicth.on_trigger = on_trigger
swicth.on_release = on_release

while True:
    time.sleep(1)

Classes

class grove.grove_tilt_switch.GroveTiltSwitch(pin)[source]

Grove Tilt Switch class

Parameters:

pin (int) – the number of gpio/slot your grove device connected.

Inheritance

digraph inheritance5b05a04a95 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "GPIO" [URL="grove.gpio.gpio_rpi.html#grove.gpio.gpio_rpi.GPIO",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "GroveTiltSwitch" [URL="#grove.grove_tilt_switch.GroveTiltSwitch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Grove Tilt Switch class"]; "GPIO" -> "GroveTiltSwitch" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
property on_release
Property access with
callback – a callable function/object,

will be called when there is a switch releasing.

callback prototype:

callback() Returns: none

Examples

set

obj.on_release = callback

get

callobj = obj.on_release
property on_trigger
Property access with
callback – a callable function/object,

will be called when there is a switch shorting/on.

callback prototype:

callback() Returns: none

Examples

set

obj.on_trigger = callback

get

callobj = obj.on_trigger