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


Python ADC0832类代码示例

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


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

示例1: setup

def setup():
	ADC0832.setup()				# Setup ADC0832
	GPIO.setmode(GPIO.BOARD)	# Numbers GPIOs by physical location
	GPIO.setup(btn, GPIO.IN, pull_up_down=GPIO.PUD_UP)	# Setup button pin as input an pull it up
	GPIO.add_event_detect(btn, GPIO.FALLING, callback=button_pressed, bouncetime=100)
	global state
	state = ['up', 'down', 'left', 'right']	
开发者ID:DarrenGansberg,项目名称:Adeept_RFID_Learning_Kit_Python_Code_for_RPi,代码行数:7,代码来源:25_joystick.py

示例2: joystickState

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,代码行数:9,代码来源:30_expand02.py

示例3: readPhotoSens

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,代码行数:10,代码来源:led_dht_test.py

示例4: getResult

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,代码行数:13,代码来源:25_joystick.py

示例5: getResult

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,代码行数:13,代码来源:25_joystick.py

示例6: loop

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,代码行数:7,代码来源:main.py

示例7: loop

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,代码行数:7,代码来源:ledBar.py

示例8: loop

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,代码行数:8,代码来源:12_illumCtrl.py

示例9: loop

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,代码行数:9,代码来源:18_thermistor.py

示例10: loop

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,代码行数:9,代码来源:10_analogTemp.py

示例11: setup

def setup():
	GPIO.setmode(GPIO.BOARD)
	# Buzzer setup:
	GPIO.setup(Buzzer, GPIO.OUT)
	GPIO.output(Buzzer, 1)
	# RGB setup:
	GPIO.setup(LedRed, GPIO.OUT)
	GPIO.setup(LedGreen, GPIO.OUT)
	GPIO.setup(LedBlue, GPIO.OUT)
	GPIO.output(LedRed, 1)
	GPIO.output(LedGreen, 1)
	GPIO.output(LedBlue, 1)
	# DS18B20 setup:
	ds18b20Init()
	# Joystick setup:
	GPIO.setup(btn, GPIO.IN)
	GPIO.add_event_detect(btn, GPIO.FALLING, callback=joystickbtn, bouncetime=200)
	# ADC0832 setup:
	ADC0832.setup()
开发者ID:DigiTempReader,项目名称:Sunfounder_SensorKit_Python_code_for_RaspberryPi,代码行数:19,代码来源:30_expand02.py

示例12: loop

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,代码行数:11,代码来源:14_rain_detection.py

示例13: loop

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,代码行数:16,代码来源:mq-2.py

示例14: setup

def setup():
	ADC0832.setup()				# Setup ADC0832
	GPIO.setmode(GPIO.BOARD)	# Numbers GPIOs by physical location
	GPIO.setup(btn, GPIO.IN, pull_up_down=GPIO.PUD_UP)	# Setup button pin as input an pull it up
	global state
	state = ['up', 'down', 'left', 'right']	
开发者ID:chenzhendong,项目名称:adeept,代码行数:6,代码来源:25_joystick.py

示例15: init

def init():
	GPIO.setmode(GPIO.BOARD)	
	GPIO.setup(MIC_DO_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	ADC0832.setup()
开发者ID:DigiTempReader,项目名称:Sunfounder_SensorKit_Python_code_for_RaspberryPi,代码行数:4,代码来源:24_microphone.py


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