本文整理汇总了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)
示例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");
示例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)
示例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)
示例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
示例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()
示例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()
示例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: