當前位置: 首頁>>代碼示例>>Python>>正文


Python Arduino.close方法代碼示例

本文整理匯總了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()
開發者ID:0-1-0,項目名稱:Python-Arduino-Command-API,代碼行數:14,代碼來源:test_main.py

示例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()
開發者ID:0-1-0,項目名稱:Python-Arduino-Command-API,代碼行數:18,代碼來源:test_main.py

示例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()

        
開發者ID:hotpoor,項目名稱:PlayerPiano-mushroomCloud,代碼行數:31,代碼來源:test2017-06-27.py


注:本文中的Arduino.Arduino.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。