本文整理汇总了Python中GPIO.write方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.write方法的具体用法?Python GPIO.write怎么用?Python GPIO.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GPIO
的用法示例。
在下文中一共展示了GPIO.write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ledon
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import write [as 别名]
def ledon(): # function for turning on an led
print "turn on"
GPIO.write(led,1)
示例2: ledoff
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import write [as 别名]
def ledoff(): #function for turning off an led
print "turn off"
GPIO.write(led,0)
示例3: move
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import write [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)