当前位置: 首页>>代码示例>>Python>>正文


Python Arduino.analogRead方法代码示例

本文整理汇总了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)
开发者ID:sutt,项目名称:robojune,代码行数:21,代码来源:flaskread.py

示例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()

开发者ID:varunrau,项目名称:PenguinGrader,代码行数:31,代码来源:penguingrader.py

示例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)
开发者ID:Bocin58,项目名称:Python-Arduino-Proto-API-v2,代码行数:14,代码来源:sample_analogread.py

示例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
开发者ID:Bocin58,项目名称:Python-Arduino-Proto-API-v2,代码行数:24,代码来源:sample_analogwrite.py

示例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)
开发者ID:yeskarthik,项目名称:When-we-played-with-Arduino,代码行数:24,代码来源:monitor_brightness.py


注:本文中的arduino.Arduino.analogRead方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。