grove.grove_switch
¶
- This is the code for
Examples
from grove.grove_switch import GroveSwitch
import time
# connect to pin 5 (slot D5)
PIN = 5
swicth = GroveSwitch(PIN)
while True:
if swicth.state:
print("high")
else:
print("low")
time.sleep(1)
Classes¶
GroveSwitch
: Grove Switch class
- class grove.grove_switch.GroveSwitch(pin)[source]¶
Grove Switch class
- Parameters:
pin (int) – the number of gpio/slot your grove device connected.
Inheritance
digraph inheritance3fd5f5dbb8 { 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"]; "GroveSwitch" [URL="#grove.grove_switch.GroveSwitch",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 Switch class"]; "GPIO" -> "GroveSwitch" [arrowsize=0.5,style="setlinewidth(0.5)"]; }- property state¶
Read only property to get switch status.
- Returns:
True: switch high
False: switch low
- Return type:
(bool)