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


Python Arduino.digitalWrite方法代碼示例

本文整理匯總了Python中Arduino.Arduino.digitalWrite方法的典型用法代碼示例。如果您正苦於以下問題:Python Arduino.digitalWrite方法的具體用法?Python Arduino.digitalWrite怎麽用?Python Arduino.digitalWrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Arduino.Arduino的用法示例。


在下文中一共展示了Arduino.digitalWrite方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Blink

# 需要導入模塊: from Arduino import Arduino [as 別名]
# 或者: from Arduino.Arduino import digitalWrite [as 別名]
def Blink(led_pin, baud, port=""):
    board = Arduino(baud, port=port)
    board.pinMode(led_pin, "OUTPUT")
    while True:

        board.digitalWrite(led_pin, "HIGH")
        #print board.digitalRead(led_pin)  # confirm HIGH (1)
        time.sleep(1)
開發者ID:ankitasharma1,項目名稱:PillUp,代碼行數:10,代碼來源:PillUpFinal.py

示例2: __init__

# 需要導入模塊: from Arduino import Arduino [as 別名]
# 或者: from Arduino.Arduino import digitalWrite [as 別名]
class vacuum:
    def __init__(self):
        self.board=Arduino('9600');
        self.board.pinMode(13, "OUTPUT")

    def on(self):
        self.board.digitalWrite(13,"HIGH");
    def off(self):
        self.board.digitalWrite(13,"LOW");
開發者ID:duke-iml,項目名稱:ece490-s2016,代碼行數:11,代碼來源:vacuum.py

示例3: Blink

# 需要導入模塊: from Arduino import Arduino [as 別名]
# 或者: from Arduino.Arduino import digitalWrite [as 別名]
def Blink(led_pin,baud, port = ""):
    """
    Blinks an LED in 1 sec intervals
    """
    board = Arduino(baud, port=port)
    while True:
        board.digitalWrite(led_pin,"LOW")
        print board.digitalRead(led_pin) #confirm LOW (0)
        time.sleep(1)
        board.digitalWrite(led_pin,"HIGH")
        print board.digitalRead(led_pin) #confirm HIGH (1)
        time.sleep(1)
開發者ID:TylerShaw,項目名稱:Python-Arduino-Command-API,代碼行數:14,代碼來源:examples.py

示例4: Blink

# 需要導入模塊: from Arduino import Arduino [as 別名]
# 或者: from Arduino.Arduino import digitalWrite [as 別名]
def Blink(led_pin, baud, port=""):
    """
    Blinks an LED in 1 sec intervals
    """
    board = Arduino(baud, port=port)
    board.pinMode(13, "INPUT")
    while True:
        board.digitalWrite(led_pin, "LOW")
        #print(board.digitalRead(led_pin))  # confirm LOW (0)
        print("OFF")
        time.sleep(1)
        board.digitalWrite(led_pin, "HIGH")
        #print(board.digitalRead(led_pin))  # confirm HIGH (1)
        print("ON")
        time.sleep(1)   
開發者ID:ifilonenko,項目名稱:CDS-EEG,代碼行數:17,代碼來源:example.py

示例5: CommonHardwareArduino

# 需要導入模塊: from Arduino import Arduino [as 別名]
# 或者: from Arduino.Arduino import digitalWrite [as 別名]
class CommonHardwareArduino(object):
    """
    Class for interfacing with arduino device over usb
    """

    def __init__(self, baud_rate='9600', device_port="/dev/ttyACM0"):
        self.arduino_device = Arduino(baud_rate, port=device_port)

    # 'LOW'
    def com_arduino_usb_serial_digitalwrite(self, pin_number, pin_high_low='HIGH'):
        self.arduino_device.digitalWrite(pin_number, pin_high_low)

    def com_arduino_usb_serial_writestring(self, serial_string):
        self.arduino_device.SoftwareSerial.write(serial_string)

    def com_arduino_usb_serial_receivestring(self):
        pass
開發者ID:MediaKraken,項目名稱:MediaKraken_Deployment,代碼行數:19,代碼來源:common_hardware_arduino_usb_serial.py

示例6: str

# 需要導入模塊: from Arduino import Arduino [as 別名]
# 或者: from Arduino.Arduino import digitalWrite [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

示例7: Arduino

# 需要導入模塊: from Arduino import Arduino [as 別名]
# 或者: from Arduino.Arduino import digitalWrite [as 別名]
    config.config_all()
    config.save('config_piano.cfg')
#use parameters in config to setup
cam = pylaserkbd.CAM(config.camid, config.thresh, config.dilate_iterations)
board = Arduino('9600', port = "")
HISTORY_TONE = 0
pitch = ['Do', 'Re', 'Me', 'Fa', 'Sol', 'La', 'Si']
while(True):
    cam.query()
    charpts, contours = cam.retrieve()
    func = pylaserkbd.make_mapping_function_pianomode(config.corner_position)
    tones = pylaserkbd.find_tone(func, charpts)
    if len(tones) >= 2:
        tone = 8 - tones[1]
        board.pinMode(tone, 'OUTPUT')
        board.digitalWrite(tone, 'HIGH')
        if HISTORY_TONE != tone:
            board.digitalWrite(HISTORY_TONE, 'LOW')
            board.pinMode(HISTORY_TONE, 'INPUT')
            print pitch[tones[1]]
        HISTORY_TONE = tone
    elif HISTORY_TONE != -1:
        board.digitalWrite(HISTORY_TONE, 'LOW')
        board.pinMode(HISTORY_TONE, 'INPUT')
        print 'Stop'
        HISTORY_TONE = -1
    cam.show()
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cam.close()
開發者ID:ldes89150,項目名稱:pylaserkbd,代碼行數:32,代碼來源:piano.py

示例8: mainApp

# 需要導入模塊: from Arduino import Arduino [as 別名]
# 或者: from Arduino.Arduino import digitalWrite [as 別名]

#.........這裏部分代碼省略.........
            text = arg[0]
            self.status.setText(text)
        elif isinstance(arg[0], int):
            if arg[0] == 1:
                msg  = 'SHUTTER %s: TIME %s AOTF %.2f STATUS %d' % \
                (self.laserlabels[0],time.strftime('%X'),int(round(float(self.laserLine1PowerEdit.text()))),\
                self.laserLine1Shutter.checkState())
            elif arg[0] == 2:
                msg  = 'SHUTTER %s: TIME %s AOTF %.2f STATUS %d' % \
                (self.laserlabels[1],time.strftime('%X'),int(round(float(self.laserLine2PowerEdit.text()))),\
                self.laserLine2Shutter.checkState())
            elif arg[0] == 3:
                msg  = 'SHUTTER %s: TIME %s AOTF %.2f STATUS %d' % \
                (self.laserlabels[2],time.strftime('%X'),int(round(float(self.laserLine3PowerEdit.text()))),\
                self.laserLine3Shutter.checkState())
            elif arg[0] == 4:
                msg  = 'SHUTTER %s: TIME %s AOTF %.2f STATUS %d' % \
                (self.laserlabels[3],time.strftime('%X'),int(round(float(self.laserLine4PowerEdit.text()))),\
                self.laserLine4Shutter.checkState())
            elif arg[0] == 5:
                msg  = 'SHUTTER %s: TIME %s AOTF %.2f STATUS %d' % \
                (self.laserlabels[4],time.strftime('%X'),int(round(float(self.laserLine5PowerEdit.text()))),\
                self.laserLine5Shutter.checkState())
            self.status.setText(msg)
            #if self.logfile!=None:
            #open(self.logfile,'a').write(text+'\n')
        
    def seq1ActionFcn(self):
        ## parse laser intensity
        # laser 1
        laser1Intensity = self.parseInput(self.seq1Laser1Intensity.text())
        laser2Intensity = self.parseInput(self.seq1Laser2Intensity.text())
        if self.triggerCCD.isChecked():
            self.board.digitalWrite(self.arduinoPin, "HIGH")
            print('set HIGH')
        if laser1Intensity is not None:
            print ('go laser1Intensity is no None')
            if laser2Intensity is not None:
                print ('go laser2Intensity is None')
                if len(laser1Intensity) != len(laser2Intensity):
                    em = QtGui.QErrorMessage(self)
                    em.showMessage('Laser Intensity Must be Equal !!')
                    return
                else:
                    for i in range(int(self.seq1NCycles.text())):
                        self.status.setText('Cycle #' + str(i))
                        for iIntensity in range(len(laser1Intensity)):
                            if not self.seq1StopFlag:
                                self.actionPulse(self.seq1Laser1Label.currentIndex()+1, laser1Intensity[iIntensity])
                            else:
                                break
                            if not self.seq1StopFlag:
                                self.actionPulse(self.seq1Laser2Label.currentIndex()+1, laser2Intensity[iIntensity])
                            else:
                                break
            else:
                for i in range(int(self.seq1NCycles.text())):
                    self.status.setText('Cycle #' + str(i + 1))
                    for iIntensity in range(len(laser1Intensity)):
                        if not self.seq1StopFlag:
                            self.actionPulse(self.seq1Laser1Label.currentIndex()+1, laser1Intensity[iIntensity])
                        else:
                            break
                        if not self.seq1StopFlag:
                            self.actionPulse(self.seq1Laser2Label.currentIndex()+1)
                        else:
開發者ID:tiabph,項目名稱:pyAOTF,代碼行數:70,代碼來源:Main.py


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