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


Python Arduino.analogRead方法代码示例

本文整理汇总了Python中nanpy.Arduino.analogRead方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.analogRead方法的具体用法?Python Arduino.analogRead怎么用?Python Arduino.analogRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nanpy.Arduino的用法示例。


在下文中一共展示了Arduino.analogRead方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_pots

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def get_pots():
	"""
	Grab a reading from each of the pot pins and 
	send it to a tuple to be read by the colour mixer
	"""
	r = Arduino.analogRead(pot_r_Pin) / 4
	Arduino.delay(1)
	g = Arduino.analogRead(pot_g_Pin) / 4
	Arduino.delay(1)
	b = Arduino.analogRead(pot_b_Pin) / 4
	Arduino.delay(1)
	return r, g, b
开发者ID:russb78,项目名称:RGB-mixer,代码行数:14,代码来源:Colour_mix_project.py

示例2: read_sensors

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def read_sensors():
    """
    Reads each of the Sharp sensors are returns a list of analog readings
    in order: front, right, left, rear
    """
    reading = []
    for i in [FrontBump, RightBump, LeftBump, RearBump]:
        reading.append(Arduino.analogRead(i))
        Arduino.delay(1)
    return reading
开发者ID:survinderpal,项目名称:RDuD2,代码行数:12,代码来源:sensorfuncs.py

示例3: analogpin

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def analogpin(pin_number):
    if request.method == 'GET':
        Arduino.pinMode(pin_number, Arduino.INPUT)
        data = {
            'value' : Arduino.analogRead(pin_number)
        }
        resp = Response(json.dumps(data), status=200, mimetype='application/json')
        return resp
    else:
        Arduino.pinMode(pin_number, Arduino.OUTPUT)
        Arduino.analogWrite(pin_number, request.json['value'])
        resp = Response("", status=200, mimetype='application/json')
        return resp
开发者ID:RobertJamesMason,项目名称:eggsamples,代码行数:15,代码来源:arduino.py

示例4: index

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
    def index(self,request):

        json = 0
        data = 0    
            
        if request.args.get('json', '') == "1":
            json = 1
            ser = Arduino()
            data = self.receiving(ser)
            sensorValue = Arduino.analogRead(analogPort)
            data= (sensorValue/1023.)*powervoltage*100
            print "data = ", data
        html = self.showDemoHTML(data,json)
        return html
开发者ID:ari-analytics,项目名称:tem_java,代码行数:16,代码来源:tempCore.py

示例5: phase2

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def phase2():
	av = 0
	cnt = 0
	outputpin = 0
	while True:
		rawvoltage= Arduino.analogRead(outputpin)
		millivolts= float((rawvoltage/1024.0) * 5000.0)
		celsius = (millivolts)/10.0
		tempf = (celsius * 9)/5 + 32
		msgbox('degrees Celsius: {}\n degrees Fahrenheit: {}'.format(celsius, tempf))
		lcd.setCursor(0, 0)
		lcd.printString(celsius)
		lcd.setCursor(0, 1)
		lcd.printString(tempf)
		time.sleep(10)
开发者ID:pooyapooya,项目名称:rizpardazande,代码行数:17,代码来源:phase2.py

示例6: receiving

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
    def receiving(self, ser):
	print "..recieving...."
        global last_received
#        data = 0.0
        
#        buffer = ''
#         while True:
        sensorValue = Arduino.analogRead(analogPort)
        data= (sensorValue/1023.)*powervoltage*100
#            buffer = buffer + ser.analogRead(analogPort)
#            data = temp_demo
#            if '\r\n' in buffer:
#               print ('Alas...')              
        print ("temperature=",data)
        return data
开发者ID:ari-analytics,项目名称:tem_java,代码行数:17,代码来源:tempCore.py

示例7: getKey

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def getKey():                                    # Function to Translate the analogRead values from the Keys to a Command
   val = Arduino.analogRead(14)
   if val == 1023:
      return "NONE"
   elif val < 100:
      return "RIGHT"
   elif val < 150:
      return "UP"
   elif val < 330:
      return "DOWN"
   elif val < 510:
      return "LEFT"
   elif val < 750:
      return "SEL"
   else:
      return "KBD_FAULT"
开发者ID:nikhilpularru,项目名称:RaspRadio,代码行数:18,代码来源:radio.py

示例8: showDemoHTML

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
    def showDemoHTML(self,data,json):
        ## reads an html file and does things with it
        ## there are better ways, but they are more complicated
        print "....showDemoHTML...."
        while True:
          sensorValue = Arduino.analogRead(analogPort)

          data= (sensorValue/1023.)*powervoltage*100

          if json == 1:
            f = open(CURRENTDIR +"/json.html")
            html = f.read()           
            html = html.replace("%Temperature%",str(data))
            print html            
            return html        

          else:
            f = open(CURRENTDIR +"/temp.html")
            html = f.read()
	    html = html.replace("%Temperature%",str(data))
            print ".....demo....", data 
            return html
开发者ID:ari-analytics,项目名称:tem_java,代码行数:24,代码来源:tempCore.py

示例9: get_g

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def get_g():
	g_val = Arduino.analogRead(pot_g_Pin) / 4
	Arduino.delay(1)
	return g_val
开发者ID:russb78,项目名称:RGB-mixer,代码行数:6,代码来源:RGB-mixer.py

示例10: print

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
from nanpy import Arduino as A

SENSOR_PIN_A0 = 14 
BASELINE_TEMP = 20.0

# SETUP
A.pinMode(2, A.OUTPUT)
A.digitalWrite(2, A.LOW)
A.pinMode(3, A.OUTPUT)
A.digitalWrite(3, A.LOW)
A.pinMode(4, A.OUTPUT)
A.digitalWrite(4, A.LOW)

# LOOP
while True:
    sensorVal = A.analogRead(SENSOR_PIN_A0)
    voltage = (sensorVal / 1024.0) * 5.0
    temperature = (voltage - 0.5) * 100
    print("Sensor value: " + str(sensorVal) + ", Volts: " + str(voltage)  +", Degrees C: " + str(temperature) + ".")
    
    # if the current temperature is lower than the baseline turn off all LEDs
    if temperature < BASELINE_TEMP:
        A.digitalWrite(2, A.LOW)
        A.digitalWrite(3, A.LOW)
        A.digitalWrite(4, A.LOW)
    # if the temperature rises 2-4 degrees, turn an LED on 
    elif (temperature >= BASELINE_TEMP + 2 and temperature < BASELINE_TEMP + 4):
        A.digitalWrite(2, A.HIGH)
        A.digitalWrite(3, A.LOW)
        A.digitalWrite(4, A.LOW)
    # if the temperature rises 4-6 degrees, turn a second LED on  
开发者ID:mc7h,项目名称:arduino-starterkit-using-nanpy,代码行数:33,代码来源:love_o_meter.py

示例11: rear_bump

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def rear_bump():
    bump = Arduino.analogRead(RearBump)
    if bump > rearTrigger:
        return True
    else:
        return False
开发者ID:survinderpal,项目名称:RDuD2,代码行数:8,代码来源:sensorfuncs.py

示例12: left_bump

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def left_bump():
    bump = Arduino.analogRead(LeftBump)
    if bump > sideTrigger:
        return True
    else:
        return False
开发者ID:survinderpal,项目名称:RDuD2,代码行数:8,代码来源:sensorfuncs.py

示例13: right_bump

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def right_bump():
    bump = Arduino.analogRead(RightBump)
    if bump > sideTrigger:
        return True
    else:
        return False
开发者ID:survinderpal,项目名称:RDuD2,代码行数:8,代码来源:sensorfuncs.py

示例14: front_bump

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
def front_bump():  # check for bump, if bump detected return 1
    bump = Arduino.analogRead(FrontBump)
    if bump > frontTrigger:
        return True
    else:
        return False
开发者ID:survinderpal,项目名称:RDuD2,代码行数:8,代码来源:sensorfuncs.py

示例15: sleep

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogRead [as 别名]
    bright = bright + 8
    if (bright > 200):          # LED already full on at this point
        bright = 0          # Minimum power to LED
    Arduino.analogWrite(LED, bright)           # Change PWM setting/brightness
    sleep(0.05)

Arduino.digitalWrite(LED,Arduino.LOW)          # Turn off LED
print"Finished"
print "now showing the temperature...."
#stream = py.Stream(plotly_user_config['plotly_streaming_tokens'][0])
#stream.open()
cnt = 0

try:
    while True:
        sensorValue = Arduino.analogRead(analogPort)
        temperature = (sensorValue/1023.)*powervoltage*100
     #   f = open('temp.txt','a')
    #    f.write("room 1  " + str(datetime.datetime.now()) + "  " + str(temperature) + "\n")
        print "room 1 ", datetime.datetime.now() ,"  ",temperature
        # write the data to plotly
        #stream.write({'x': datetime.datetime.now(), 'y': temperature})
        tempC.append(temperature)
	drawnow(makeFig)
#	plt.plot(tempC)
#	mpld3.show()
	plt.pause(.00001)
	cnt=cnt+1
	print "cnt=   ", cnt
	if(cnt>50):
		tempC.pop(0)
开发者ID:ari-analytics,项目名称:myPython,代码行数:33,代码来源:tempc.py


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