本文整理汇总了Python中LMK.GPIO.setmode方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.setmode方法的具体用法?Python GPIO.setmode怎么用?Python GPIO.setmode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LMK.GPIO
的用法示例。
在下文中一共展示了GPIO.setmode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setmode [as 别名]
def init(self):
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(self.pin1,GPIO.OUT)
GPIO.setup(self.pin2,GPIO.OUT)
GPIO.setup(self.pin3,GPIO.OUT)
GPIO.setup(self.pin4,GPIO.OUT)
self.zeroPosition()
return
示例2: runTest
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setmode [as 别名]
def runTest(self):
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN_BCM, GPIO.IN)
self.assertEqual(GPIO.gpio_function(LED_PIN_BCM), GPIO.IN)
GPIO.setup(LED_PIN_BCM, GPIO.OUT)
self.assertEqual(GPIO.gpio_function(LED_PIN_BCM), GPIO.OUT)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(LED_PIN, GPIO.IN)
self.assertEqual(GPIO.gpio_function(LED_PIN), GPIO.IN)
GPIO.setup(LED_PIN, GPIO.OUT)
self.assertEqual(GPIO.gpio_function(LED_PIN), GPIO.OUT)
示例3: testOutput
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setmode [as 别名]
def testOutput(mode, pins):
if mode == "BOARD":
print "Start to test the mode: %s" %(mode)
GPIO.setmode(GPIO.BOARD)
elif mode == "BCM":
print "Start to test the mode: %s" %(mode)
GPIO.setmode(GPIO.BCM)
else:
print "Invalid test mode: %s" %(mode)
for i in pins:
try:
GPIO.setup(i, GPIO.OUT)
except:
print("Failed to setup GPIO %d", i)
continue
GPIO.output(i, True)
time.sleep(0.5)
GPIO.output(i, False)
time.sleep(0.5)
GPIO.cleanup()
示例4: testPwm
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setmode [as 别名]
def testPwm(mode, pins):
if mode == "BOARD":
print "Start to test the mode: %s" %(mode)
GPIO.setmode(GPIO.BOARD)
elif mode == "BCM":
print "Start to test the mode: %s" %(mode)
GPIO.setmode(GPIO.BCM)
else:
print "Invalid test mode: %s" %(mode)
for i in pins:
GPIO.setup(i,GPIO.OUT)
p = GPIO.PWM(i,100) #set freq: 100HZ
p.start(10) #duty cycle: 10%
time.sleep(1)
p.start(100) #duty cycle: 100%
time.sleep(1)
GPIO.output(i, False)
p.stop()
GPIO.cleanup()
示例5:
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setmode [as 别名]
'''
import LMK.GPIO as GPIO
import time
#pull-up/down pins for the LeMaker Guitar, and the P3, P5, P19 and P23 of the pull-up has been enabled by
#connecting the external pull-up resistor, don't need to operate by using the software.
#-----------P8 P10 P12 P13 P15 P16 P22-----------#
pullUpGt = (8, 10, 12, 13, 15, 16, 22) #Pull-UP pins which be configured by the software
pullDwGt = (16,) #Pull-Down pins which be configured by the software
#pull-up/down pins for the BananaPro, and the P3, P5, P27 and P28 of the pull-up have been enabled by
#connecting the external pull-up resistor, don't need to operate by using the software.
#-----------P7 P8 P10 P11 P12 P13 P15 P16 P18 P19 P21 P22 P23 P24 P26 P29 P31 P32 P33 P35 P36 P37 P38 P40-----------#
pullUpBP = (7, 8, 10, 11, 12, 13, 15, 16, 18, 19, 21, 22, 23, 24, 26, 29, 31, 32, 33, 35, 36, 37, 38, 40)
PullDwBP = (7, 8, 10, 11, 12, 13, 15, 16, 18, 19, 21, 22, 23, 24, 26, 29, 31, 32, 33, 35, 36, 37, 38, 40)
#GPIO.PUD_UP #enable pull-up
#GPIO.PUD_DOWN #enable pull-down
#GPIO.PUD_OFF #disable pull-up/down
GPIO.setmode(GPIO.BOARD)
for i in pullUpGt:
GPIO.setup(i, GPIO.IN, pull_up_down=GPIO.PUD_UP) #enable pull-up
time.sleep(1)
GPIO.setup(i, GPIO.IN, pull_up_down=GPIO.PUD_OFF) #disable pull-up
time.sleep(0)
GPIO.cleanup()
示例6: my_callback
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setmode [as 别名]
import LMK.GPIO as GPIO
import time
#PIN_NUM = 24
#GPIO.setmode(GPIO.BOARD)
#GPIO.setup(PIN_NUM,GPIO.IN,GPIO.PUD_DOWN)
GPIO.setmode(GPIO.RAW)
GPIO.setup(GPIO.PI+10,GPIO.IN,GPIO.PUD_DOWN)
print "The value of Pin %d is %d" %(GPIO.PI+10,GPIO.input(GPIO.PI+10))
def my_callback(channel):
print "Callback trigger %d" %channel
print "Now value of the Pin is %d" %(GPIO.input(GPIO.PI+10))
print "Click Ctr + C to exit"
GPIO.add_event_detect(GPIO.PI+10,GPIO.RISING,callback = my_callback,bouncetime = 300)
try:
while True:
time.sleep(0.1)
except KeyboardInterrupt:
pass
GPIO.cleanup()
示例7: Tk
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setmode [as 别名]
import binascii
import datetime
from Tkinter import Tk
from array import array
import LMK.GPIO as GPIO
import step_motor as StepMotor
import RTC_DS1307
import IOboard
ver_BOARD = GPIO.LMK_REVISION
if ver_BOARD == 2:
import DHTreader2 as DHTreader
if ver_BOARD == 3:
import DHTreader3 as DHTreader
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(True)
stepM1 = StepMotor.Motor(11,7,16,26)
stepM2 = StepMotor.Motor(4,25,24,23)
root = Tk()
root.withdraw()
Bus = smbus.SMBus(2)
PORT = 42001
HOST = "localhost"
Debug = False
Connected = False
Setup = False