本文整理汇总了Python中Arduino.Arduino.close方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.close方法的具体用法?Python Arduino.close怎么用?Python Arduino.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arduino.Arduino
的用法示例。
在下文中一共展示了Arduino.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import close [as 别名]
def test_find(self):
""" Tests auto-connection/board detection. """
raw_input(
'Plug in Arduino board w/LED at pin 13, reset, then press enter')
from Arduino import Arduino
board = None
try:
# This will trigger automatic port resolution.
board = Arduino(9600)
finally:
if board:
board.close()
示例2: test_open
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import close [as 别名]
def test_open(self):
""" Tests connecting to an explicit port. """
port = None
while not port:
port = raw_input(
'Plug in Arduino board w/LED at pin 13, reset.\n'\
'Enter the port where the Arduino is connected, then press enter:')
if not port:
print 'You must enter a port.'
from Arduino import Arduino
board = None
try:
board = Arduino(9600, port=port)
finally:
if board:
board.close()
示例3: str
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import close [as 别名]
#print(msg)
msgList = str(msg).split(' ')
if msgList[0] == 'note_on':
channel = msgList[1][8:]
note = msgList[2][5:]
velocity = msgList[3][9:]
delay = msgList[4][5:]
playList.append([channel, note, velocity])
timeDelay.append(delay)
pygame.init()
pygame.mixer_music.load('004.MID') # load midi file with pygame.mixer_music, ready to play
pygame.mixer_music.play() #play midi music
while True:
try:
print("stageA")
board.digitalWrite(13,"HIGH")
board.Servos.write(4, 0)
time.sleep(1)
print("stageB")
board.Servos.write(4, 90)
board.digitalWrite(13,"LOW")
time.sleep(1)
except KeyboardInterrupt:
print("exit...")
board.close()
pygame.mixer_music.stop()