本文整理汇总了Python中arduino.Arduino.analogRead方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.analogRead方法的具体用法?Python Arduino.analogRead怎么用?Python Arduino.analogRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arduino.Arduino
的用法示例。
在下文中一共展示了Arduino.analogRead方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pollj
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import analogRead [as 别名]
def pollj():
ret = []
pin = 1
try:
b = Arduino('/dev/ttyACM0')
b.output([])
except:
print 'couldnt create b'
for i in range(10):
val = None
try:
val = b.analogRead(pin)
except:
print 'couldnt analogread ' + str(i)
ret.append(val)
print val
time.sleep(0.5)
return " | ".join(ret)
示例2: Arduino
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import analogRead [as 别名]
from bottle import route, run, template, get, view
from Queue import Queue
import threading
from arduino import Arduino
import time
b = Arduino("/dev/tty.usbmodemfd121")
b.output([])
input_pin = 1
max_threshold = 0
min_threshold = 0
for y in range(100):
x = int(b.analogRead(input_pin))
print x
max_threshold = max([max_threshold, x])
min_threshold = min([min_threshold, x])
print "+++++++++++++++++++++++"
print max_threshold
print min_threshold
print "+++++++++++++++++++++++"
@route("/")
@view("main_template")
def index(name="Michel"):
return dict()
示例3: Arduino
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import analogRead [as 别名]
from arduino import Arduino
import time
b = Arduino('/dev/ttyUSB0')
pin = 1
b.output([])
while (True):
val = b.analogRead(pin)
print val
time.sleep(0.5)
示例4: Arduino
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import analogRead [as 别名]
from arduino import Arduino
import time
b = Arduino('/dev/ttyUSB0')
pin = 9
#declare output pins as a list/tuple
b.output([pin])
brightness = 0
fadeAmount = 3
b.output([pin])
while (True):
b.analogWrite(pin, brightness)
time.sleep(0.05)
print b.analogRead(pin)
brightness = brightness + fadeAmount
if (brightness == 0 or brightness == 255):
fadeAmount = -fadeAmount
示例5: Arduino
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import analogRead [as 别名]
from arduino import Arduino
import os
import time
myboard = Arduino('/dev/ttyUSB3')
#myboard.input([17])
i=0
while i<100:
ambient_light = myboard.analogRead(17)
print ambient_light
if ambient_light > 600 :
brightness = 10
elif ambient_light > 300:
brightness = 50
else :
brightness = 100
os.system("echo "+str(brightness)+"> /proc/acpi/video/GFX0/DD03/brightness")
i+=1
time.sleep(100)