本文整理匯總了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()