当前位置: 首页>>代码示例>>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;未经允许,请勿转载。