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


Python ADC0832.getResult方法代码示例

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


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

示例1: joystickState

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def joystickState():
	if ADC0832.getResult1() == 0:
		return 1		#up
	if ADC0832.getResult1() == 255:
		return 2		#down
	if ADC0832.getResult() == 0:
		return 3		#left
	if ADC0832.getResult() == 255:
		return 4		#right
开发者ID:DigiTempReader,项目名称:Sunfounder_SensorKit_Python_code_for_RaspberryPi,代码行数:11,代码来源:30_expand02.py

示例2: getResult

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def getResult():	#get joystick result
	x_axis = 0
	y_axis = 1
	x = ADC0832.getResult(x_axis)	
	if x == 0:
		return 4
	elif x == 255: 
		return 3
	y = ADC0832.getResult(y_axis)
	if y == 0:
		return 1
	elif y == 255:
		return 2
开发者ID:DarrenGansberg,项目名称:Adeept_RFID_Learning_Kit_Python_Code_for_RPi,代码行数:15,代码来源:25_joystick.py

示例3: getResult

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def getResult():	#get joystick result
	if ADC0832.getResult1() == 0:
		return 1		#up
	if ADC0832.getResult1() == 255:
		return 2		#down

	if ADC0832.getResult() == 0:
		return 3		#left
	if ADC0832.getResult() == 255:
		return 4		#right

	if GPIO.input(btn) == 1:
		print 'Button is pressed!'		# Button pressed
开发者ID:chenzhendong,项目名称:adeept,代码行数:15,代码来源:25_joystick.py

示例4: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	while True:
		t = ADC0832.getResult()
		vol = 5.0/255 * t
		vol = round(vol, 2)
		segment.numberDisplay_dec(vol)
		time.sleep(0.1)      
开发者ID:adeept,项目名称:Adeept_Sensor_Kit_for_RPi_Python_Code,代码行数:9,代码来源:main.py

示例5: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	while True:
		res = ADC0832.getResult()
		print 'res = %d' % res
		num = map(res, 0, 255, 0, 10)
		ledBarCtrl(num)
		time.sleep(0.2)
开发者ID:DarrenGansberg,项目名称:Adeept_RFID_Learning_Kit_Python_Code_for_RPi,代码行数:9,代码来源:ledBar.py

示例6: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	while True:
		analogVal = ADC.getResult(0)
		print 'adcval:', analogVal
		if analogVal > 0:
			print 'temp:', convert_to_temperature(analogVal)
		time.sleep(sleep_time)
开发者ID:stevenvo,项目名称:rpi-gpio-scripts,代码行数:9,代码来源:10_thermistor.py

示例7: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	p = GPIO.PWM(LedPin, 1000) # Set PWM Frequence to 1000Hz
	p.start(0)
	while True:
		res = ADC0832.getResult()
		if res > 100:
			res = 100
		p.ChangeDutyCycle(res)   # Change the duty cycle according to res
开发者ID:alexmihaila64,项目名称:Sunfounder_BaseKit_Python_Code_for_RaspberryPi,代码行数:10,代码来源:12_illumCtrl.py

示例8: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	while True:
		analogVal = ADC.getResult(0)
		print 'adcval:', analogVal
		if analogVal > 200:
			beep()
		else:
			time.sleep(0.5)
开发者ID:stevenvo,项目名称:rpi-gpio-scripts,代码行数:10,代码来源:14_tempMonitor.py

示例9: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	while True:
		res = ADC0832.getResult()
		if res < 0:
			res = 0
		if res > 100:
			res = 100
		print 'res = %d' % res
		time.sleep(0.2)
开发者ID:DarrenGansberg,项目名称:Adeept_RFID_Learning_Kit_Python_Code_for_RPi,代码行数:11,代码来源:18_thermistor.py

示例10: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	while True:
		analogVal = ADC0832.getResult()
		Vr = 5 * float(analogVal) / 255
		Rt = 10000 * Vr / (5 - Vr)
		temp = 1/(((math.log(Rt / 10000)) / 3950) + (1 / (273.15+25)))
		temp = temp - 273.15
		print 'temperature = %d C' % temp
		time.sleep(0.2)
开发者ID:DigiTempReader,项目名称:Sunfounder_SensorKit_Python_code_for_RaspberryPi,代码行数:11,代码来源:10_analogTemp.py

示例11: readPhotoSens

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def readPhotoSens(chn=0):
  print "Reading light from channel: %d" % chn
  ADC0832.setup()
  photores = ADC0832.getResult(chn) - 80
  if photores < 0:
    photores = 0
  if photores > 100:
    photores = 100
  print 'Relative light = %d' % photores
  time.sleep(0.2)
开发者ID:froggleston,项目名称:scripts,代码行数:12,代码来源:led_dht_test.py

示例12: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	while True:
		rainVal = ADC0832.getResult(0)
		print GPIO.input(RAIN)
		if GPIO.input(RAIN) == 0:
			print '***************'
			print '* !!RAINING!! *'
			print '***************'
			print ''
		print rainVal
		time.sleep(0.5)
开发者ID:HandcraftCavon,项目名称:SSK,代码行数:13,代码来源:14_rain_detection.py

示例13: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	while True:
		analogVal = ADC.getResult(0)
		print "value =", analogVal
		illum = map(analogVal, 130, 255, 0, 100)
		if illum > 80:
			illum = 80
		if illum < 0:
			illum = 0
		p.ChangeDutyCycle(illum)
		print illum
		time.sleep(0.05)
开发者ID:stevenvo,项目名称:rpi-gpio-scripts,代码行数:14,代码来源:13_illumCtrl.py

示例14: loop

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
def loop():
	while True:
		tmp = ADC0832.getResult()			# Get analog value from ADC0832
		print tmp							# Print analog value
		if tmp > TS :						# Beep when read value greater than threshold
			print '    ****************'
			print '    * !! DANGER !! *'
			print '    ****************'
			print ''
				
			GPIO.output(BEEP, GPIO.HIGH)	# (0, means detect danger gas)
			time.sleep(0.25)
			GPIO.output(BEEP, GPIO.LOW)
			time.sleep(0.25)
		else :
			time.sleep(0.5)					# Else delay printing.
开发者ID:DigiTempReader,项目名称:Sunfounder_SensorKit_Python_code_for_RaspberryPi,代码行数:18,代码来源:mq-2.py

示例15: push_message

# 需要导入模块: import ADC0832 [as 别名]
# 或者: from ADC0832 import getResult [as 别名]
 def push_message(self):
     analogVal = ADC.getResult(0)
     distance = (6762/(analogVal-9))-4
     if distance > 0:
         self.write_message(str(distance))
     tornado.ioloop.IOLoop.instance().add_timeout(datetime.timedelta(seconds=1), self.push_message)
开发者ID:scareface972,项目名称:smart-mirror-1,代码行数:8,代码来源:app.py


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