本文整理汇总了Python中Arduino.Arduino.analogRead方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.analogRead方法的具体用法?Python Arduino.analogRead怎么用?Python Arduino.analogRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arduino.Arduino
的用法示例。
在下文中一共展示了Arduino.analogRead方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ButtonTry
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import analogRead [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: adjustBrightness
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import analogRead [as 别名]
def adjustBrightness(pot_pin, led_pin, baud, port=""):
"""
Adjusts brightness of an LED using a
potentiometer.
"""
board = Arduino(baud, port=port)
while True:
time.sleep(0.01)
val = board.analogRead(pot_pin) / 4
print val
board.analogWrite(led_pin, val)
示例3: Button
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import analogRead [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)
示例4: AccelRead
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import analogRead [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)
示例5: ButtonPill
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import analogRead [as 别名]
def ButtonPill():
board = Arduino(9600, "")
i = 0
Counter = 10
CounterCopy = Counter
while True:
inp = board.analogRead(0)
i = i + 1
print "[" + str(i) + "]\t" + str(inp)
if inp > 0:
Counter = Counter - 1
if Counter <= 2:
message = client.messages.create(
body="Hey there!\n" +
"Looks like your medication needs to be restocked!\n" +
"We have taken care of that for you! Ready to be picked up whenever you are ready :)",
to="+19737234645",
from_="+12677133663")
message = client.messages.create(
body="Hey there!\n" +
"Looks like Ankita''s medication needs to be restocked!\n" +
"We have taken informed her as well!",
to="+14702633590",
from_="+12677133663")
elif Counter < (CounterCopy/2):
message = client.messages.create(
body="Hey there!\n" +
"Looks like your doing well there friend!\n" +
"Make sure your taking your medication on time!",
to="+19737234645",
from_="+12677133663")
time.sleep(0.3)
示例6: Arduino
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import analogRead [as 别名]
from __future__ import division
from Arduino import Arduino
board = Arduino('9600', '/dev/tty.usbserial-A602TSPH')
while True:
try:
val = board.analogRead(0)
voltage = val * (5.0 / 1023.0)
print voltage
except:
print "N/A"
示例7: print
# 需要导入模块: from Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino import analogRead [as 别名]
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()
exit()