本文整理汇总了Python中GPIO.setup方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.setup方法的具体用法?Python GPIO.setup怎么用?Python GPIO.setup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GPIO
的用法示例。
在下文中一共展示了GPIO.setup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setup [as 别名]
def __init__(self):
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(self.pp_pin, GPIO.OUT)
GPIO.setup(self.tmp_pin, GPIO.OUT)
GPIO.setup(self.hvgv_pin, GPIO.OUT)
GPIO.setup(self.vv_pin, GPIO.OUT)
示例2: __init__
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setup [as 别名]
def __init__(self, queue):
self.queue = queue
GPIO.setmode(GPIO.BCM)
GPIO.setup(self.sw_pp_pin, GPIO.IN)
GPIO.setup(self.sw_tmp_pin, GPIO.IN)
GPIO.setup(self.sw_hvgv_pin, GPIO.IN)
GPIO.setup(self.sw_vv_pin, GPIO.IN)
GPIO.setwarnings(False)
self._stop = threading.Event()
self.thread = threading.Thread(target=self.run)
self.thread.setName("SwitchesRaspberry")
self._stop.clear()
self.thread.start()
示例3: __init__
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setup [as 别名]
def __init__(self):
# set up the SPI interface pins
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(spimosi, GPIO.OUT)
GPIO.setup(spimiso, GPIO.IN)
GPIO.setup(spiclk, GPIO.OUT)
GPIO.setup(spics, GPIO.OUT)
print("Sensors pins setup")
self._stop = threading.Event()
self.thread = threading.Thread(target=self.run)
self.thread.setName("SensorsRaspberry")
self._stop.clear()
self.thread.start()
示例4: ledon
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setup [as 别名]
#!/usr/bin/python
from Tkinter import *
import GPIO # importing GPIO library
led = 4 # assigning the gpio_4 to variable led
GPIO.export(led) # exporting the gpio_4
GPIO.setup(led,1) # make the gpio_4 as output pin by the value 1
def ledon(): # function for turning on an led
print "turn on"
GPIO.write(led,1)
def ledoff(): #function for turning off an led
print "turn off"
GPIO.write(led,0)
root =Tk()
button1 = Button(root,text="ON",command=ledon) #assigning the function ledon to the button "ON"
button2 = Button(root,text="OFF",command=ledoff) #assigning the function ledoff to the button "OFF"
button1.pack(side = LEFT ) #alignment for the button "ON"
button2.pack(side = RIGHT) #alignment for the button "OFF"
root.mainloop()
示例5: move
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setup [as 别名]
class move(object):
""" This class drives the robot around given the pin numbers it's connected to"""
def __init(self,RF,RR,LF,LR):
pass
def setup(self,RF,RR,LF,LR):
"""This will set up the GPIO pins to move the robot"""
self.RF=RF
self.RR=RR
self.LF=LF
self.LR=LR
OUT='out'
IN='in'
self.pins = GPIO()
self.pins.setup(self.RF, OUT)
self.pins.setup(self.RR, OUT)
self.pins.setup(self.LF, OUT)
self.pins.setup(self.LR, OUT)
def forward(self):
"""Turns pins on to move forward"""
self.stop()
self.pins.write(self.RF,1)
self.pins.write(self.RR,0)
self.pins.write(self.LF,1)
self.pins.write(self.LR,0)
def reverse(self):
"""Turns pins on to move backward"""
self.stop()
self.pins.write(self.RF,0)
self.pins.write(self.RR,1)
self.pins.write(self.LF,0)
self.pins.write(self.LR,1)
def right(self):
"""Turns pins to pivot right"""
self.stop()
self.pins.write(self.RF,0)
self.pins.write(self.RR,1)
self.pins.write(self.LF,1)
self.pins.write(self.LR,0)
def left(self):
"""Turns pins to pivot left"""
self.stop()
self.pins.write(self.RF,1)
self.pins.write(self.RR,0)
self.pins.write(self.LF,0)
self.pins.write(self.LR,1)
def stop(self):
"""Turns all pins off to stop"""
self.pins.write(self.RF,0)
self.pins.write(self.RR,0)
self.pins.write(self.LF,0)
self.pins.write(self.LR,0)
def dispatch(self):
"""Unexport all pins used"""
self.pins.clean(self.RF)
self.pins.clean(self.RR)
self.pins.clean(self.LF)
self.pins.clean(self.LR)
示例6: __init__
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setup [as 别名]
def __init__(self):
GPIO.setmode(GPIO.BCM)
GPIO.setup(self.LCD_E, GPIO.OUT) # E
GPIO.setup(self.LCD_RS, GPIO.OUT) # RS
GPIO.setup(self.LCD_D4, GPIO.OUT) # DB4
GPIO.setup(self.LCD_D5, GPIO.OUT) # DB5
GPIO.setup(self.LCD_D6, GPIO.OUT) # DB6
GPIO.setup(self.LCD_D7, GPIO.OUT) # DB7
self._stop = threading.Event()
self.thread = threading.Thread(target=self.run)
self.thread.setName("DisplayRaspberry")
self._stop.clear()
self.thread.start()