本文整理汇总了Python中Arduino.Arduino.pinMode方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.pinMode方法的具体用法?Python Arduino.pinMode怎么用?Python Arduino.pinMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arduino.Arduino
的用法示例。
在下文中一共展示了Arduino.pinMode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ButtonTry
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
def ButtonTry():
currPin = 0
board = Arduino(9600, "")
board.pinMode(8, "INPUT")
i = 0
Counter = 7
while True:
inp = board.analogRead(0)
i = i + 1
print "[" + str(i) + "]\t" + str(inp)
if inp > 0:
Counter = Counter - 1
if Counter <= 1:
message = client.messages.create(body="'Hey there! Looks like your medication needs to be restocked! We have taken care of that for you! Ready to be picked up whenever you are ready :)",
to="+19737234645",
from_="+12677133663")
#print message.sid
#Counter = 7
elif Counter < (7 / 2):
message = client.messages.create(body="'Hey there! Looks like your doing okay there friend! Make sure your taking your medication on time!",
to="+19737234645",
from_="+12677133663")
else:
print "YOU ARE GOOD TO GO"
#print board.digitalRead(led_pin) # confirm HIGH (1)
time.sleep(0.2)
示例2: Blink
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [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)
示例3: __init__
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [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");
示例4: Lighting
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
def Lighting():
currPin = 0
board = Arduino(9600, "")
board.pinMode(0, "OUTPUT")
i = 0
while True:
#board.analogWrite(0,65)
i = i + 1
print "[" + str(i) + "]\t"
#print board.digitalRead(led_pin) # confirm HIGH (1)
time.sleep(0.1)
示例5: Button
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
def Button():
currPin = 0
board = Arduino(9600, "")
board.pinMode(8, "INPUT")
i = 0
while True:
inp = board.analogRead(0)
i = i + 1
print "[" + str(i) + "]\t" + str(inp)
#print board.digitalRead(led_pin) # confirm HIGH (1)
time.sleep(0.1)
示例6: Stepper
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
def Stepper(baud, port, steps, pin1, pin2, pin3=0, pin4=0, speed=120):
"""
Steps
"""
board = Arduino(baud, port=port)
board.pinMode(13, "OUTPUT")
board.Stepper.attach(steps,pin1, pin2, pin3, pin4)
board.Stepper.speed(pin1, speed)
while True:
board.Stepper.step(pin1, steps)
time.sleep(1)
board.Stepper.step(pin1, -steps)
time.sleep(1)
示例7: Blink
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
def Blink(led_pin, baud, port=""):
"""
Blinks an LED in 1 sec intervals
"""
board = Arduino(baud, port=port)
board.pinMode(13, "OUTPUT")
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)
示例8: AccelRead
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
def AccelRead():
board = Arduino(9600, "")
board.pinMode(13, "OUTPUT")
cX = 0
cY = 0
cZ = 0
while True:
analogX = board.analogRead(2)
analogY = board.analogRead(1)
analogZ = board.analogRead(0)
if abs(analogX - cX) > 5:
#abs(analogX - cX) > 5 | abs(analogY - cY) > 5 |
print "X:" + str(analogX) + "Y:" + str(analogY) +"Z:" + str(analogZ)
cX = analogX
cY = analogY
#print "X:" + str(analogX)
cX = analogX
#board.digitalWrite(13, "HIGH")
#print board.digitalRead(led_pin) # confirm HIGH (1)
time.sleep(0.01)
示例9: Arduino
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
print "No existing configuration found!"
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()
示例10: mainApp
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
class mainApp(QtGui.QMainWindow, Ui_MainWindow):
logfile = None
"""docstring for mainApp"""
def __init__(self, parent=None):
super(mainApp, self).__init__(parent)
self.setupUi(self)
# Load configuration file
cfgpath = os.path.split(os.path.abspath(sys.argv[0]))[0]
#if sys.argv[0] in dir():
# cfgpath=os.path.split(os.path.abspath(__file__))[0]
#else: # fix for py2exe
# cfgpath=sys.prefix
cfgpath=os.path.join(cfgpath, "cfg.txt")
self.cfg=ConfigParser.ConfigParser()
self.cfg.readfp(open(cfgpath))
# Detect number of laser lines
sections = self.cfg.sections()
if "serial port" not in sections:
raise Exception, "invalid configuration file"
self.laserlabels = sections
self.laserlabels.remove("serial port")
self.laserlabels.sort()
self.nlines=len(self.laserlabels)
self._power=[0]*self.nlines
self._shutter=[0]*self.nlines
# Detect arduino board
if "arduino port" in sections:
self.arduinoPort = self.cfg.getint("arduino port", "number") - 1
self.arduinoPin = self.cfg.getint("arduino pin", "pin")
self.board = Arduino(9600, port=self.arduinoPort)
self.board.pinMode(self.arduinoPin, "OUTPUT")
# define close event
QtCore.QObject.connect(self, QtCore.SIGNAL('triggered()'), self.closeEvent)
# bind signal and slot
for n in xrange(5):
if n == 0:
QtCore.QObject.connect(self.laserLine1Shutter,
QtCore.SIGNAL(_fromUtf8("stateChanged(int)")),
self.actionShutterLaserLine1)
QtCore.QObject.connect(self.laserLine1PowerSlider,
QtCore.SIGNAL(_fromUtf8("valueChanged(int)")),
self.actionPowerSliderLaserLine1)
QtCore.QObject.connect(self.laserLine1PowerEdit,
QtCore.SIGNAL(_fromUtf8("returnPressed()")),
self.actionPowerEditLaserLine1)
QtCore.QObject.connect(self.laserLine1Pulse,
QtCore.SIGNAL(_fromUtf8("clicked()")),
self.actionPulseLaserLine1)
elif n == 1:
QtCore.QObject.connect(self.laserLine2Shutter,
QtCore.SIGNAL(_fromUtf8("stateChanged(int)")),
self.actionShutterLaserLine2)
QtCore.QObject.connect(self.laserLine2PowerSlider,
QtCore.SIGNAL(_fromUtf8("valueChanged(int)")),
self.actionPowerSliderLaserLine2)
QtCore.QObject.connect(self.laserLine2PowerEdit,
QtCore.SIGNAL(_fromUtf8("returnPressed()")),
self.actionPowerEditLaserLine2)
QtCore.QObject.connect(self.laserLine2Pulse,
QtCore.SIGNAL(_fromUtf8("clicked()")),
self.actionPulseLaserLine2)
elif n == 2:
QtCore.QObject.connect(self.laserLine3Shutter,
QtCore.SIGNAL(_fromUtf8("stateChanged(int)")),
self.actionShutterLaserLine3)
QtCore.QObject.connect(self.laserLine3PowerSlider,
QtCore.SIGNAL(_fromUtf8("valueChanged(int)")),
self.actionPowerSliderLaserLine3)
QtCore.QObject.connect(self.laserLine3PowerEdit,
QtCore.SIGNAL(_fromUtf8("returnPressed()")),
self.actionPowerEditLaserLine3)
QtCore.QObject.connect(self.laserLine3Pulse,
QtCore.SIGNAL(_fromUtf8("clicked()")),
self.actionPulseLaserLine3)
elif n == 3:
QtCore.QObject.connect(self.laserLine4Shutter,
QtCore.SIGNAL(_fromUtf8("stateChanged(int)")),
self.actionShutterLaserLine4)
QtCore.QObject.connect(self.laserLine4PowerSlider,
QtCore.SIGNAL(_fromUtf8("valueChanged(int)")),
self.actionPowerSliderLaserLine4)
QtCore.QObject.connect(self.laserLine4PowerEdit,
QtCore.SIGNAL(_fromUtf8("returnPressed()")),
self.actionPowerEditLaserLine4)
QtCore.QObject.connect(self.laserLine4Pulse,
QtCore.SIGNAL(_fromUtf8("clicked()")),
self.actionPulseLaserLine4)
elif n == 4:
QtCore.QObject.connect(self.laserLine5Shutter,
QtCore.SIGNAL(_fromUtf8("stateChanged(int)")),
self.actionShutterLaserLine5)
QtCore.QObject.connect(self.laserLine5PowerSlider,
QtCore.SIGNAL(_fromUtf8("valueChanged(int)")),
self.actionPowerSliderLaserLine5)
QtCore.QObject.connect(self.laserLine5PowerEdit,
QtCore.SIGNAL(_fromUtf8("returnPressed()")),
#.........这里部分代码省略.........
示例11: Arduino
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
log.warning("Could not initialize temperature sensor, using dummy values!")
sensor_available = False
'''
try:
from fs9721 import Client
sensor_available = True
except:
log.warning("Could not initialize DMM for temperature")
sensor_available = False
try:
from Arduino import Arduino
gpio_available = True
gpio_board = Arduino('9600',port='/dev/ttyACM0')
gpio_board.pinMode(config.gpio_heat,"OUTPUT")
gpio_board.pinMode(config.gpio_cool,"OUTPUT")
gpio_board.pinMode(config.gpio_air,"OUTPUT")
gpio_board.pinMode(config.gpio_door,"INPUT")
except:
msg = "Could not initialize GPIOs, oven operation will only be simulated!"
log.warning(msg)
gpio_available = False
'''
try:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(config.gpio_heat, GPIO.OUT)
GPIO.setup(config.gpio_cool, GPIO.OUT)
示例12: Arduino
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
from Arduino import Arduino
import time
board = Arduino('9600') #plugged in via USB, serial com at rate 9600
board.pinMode(13, "OUTPUT")
while True:
board.digitalWrite(13, "LOW")
time.sleep(1)
board.digitalWrite(13, "HIGH")
time.sleep(1)
示例13: print
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
import turtle
from Arduino import Arduino
pin=14 #A0
startPressure=295 #the reading we get with no pressure
startSize=10 #which we will equate with drawing a radius of 10px
modifyFactor=10 #modified by a factor of 10
board=Arduino('9600', 'COM6')
board.pinMode(pin, 'INPUT')
#set up turtle pen
turtle.pen(fillcolor="purple", pencolor="black", pensize=10)
turtle.speed(0) #don't delay drawing when called
turtle.penup() #don't draw while we set up
turtle.right(90) #degrees
turtle.forward(modifyFactor*startSize)
turtle.left(90)
turtle.pendown() #start drawing
try:
while True:
pressure=board.analogRead(pin)
adjustedPressure=pressure-(startPressure-startSize)
print("pressure="+str(pressure)+
" - adjustedPressure="+str(adjustedPressure))
turtle.clear()
turtle.begin_fill()
turtle.circle(modifyFactor*adjustedPressure)
turtle.end_fill()
except (KeyboardInterrupt, SystemExit):
print('exiting')
turtle.bye()
示例14: speed
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import pinMode [as 别名]
#setting up pins for each motor's (4x4) speed (_sp) and direction (_pwm)
rx = 24;
ry = 25;
lx = 22;
ly = 23;
rsp = 3;
lsp = 2;
#setting up relay switch pins
sw_mot = 52;
sw_1 = 53;
sw_2 = 50;
sw_3 = 51;
#define pin Mode Engines
board.pinMode(rx, "OUTPUT")
board.pinMode(ry, "OUTPUT")
board.pinMode(lx, "OUTPUT")
board.pinMode(ly, "OUTPUT")
board.pinMode(rsp, "OUTPUT")
board.pinMode(lsp, "OUTPUT")
#Speed of Left wheels
def SL(pwl):
board.analogWrite(lsp, pwl);
#Speed of Right wheels
def SR(pwr):
board.analogWrite(rsp, pwr);
#Left wheels Forward