def runExample():

	print("\nSparkFun Proximity Sensor VCN4040 Example 4\n")
	oProx = qwiic_proximity.QwiicProximity()

	if oProx.connected == False:
		print("The Qwiic Proximity device isn't connected to the system. Please check your connection", \
			file=sys.stderr)
		return

	# begin Setup
	oProx.begin()

	oProx.power_on_proximity()  	# Power up the proximity portion of the sensor
	oProx.power_on_ambient()  	# Power Up the ambient sensor
	oProx.enable_white_channel()	


	while True:

		proxValue = oProx.get_proximity()
		print("Proximity Value: \t[%5d]" % proxValue)
		
		ambientValue = oProx.get_ambient()
		print("Ambient Value: \t\t[%5d]" % ambientValue)

		whiteValue = oProx.get_white()
		print("White Value: \t\t[%5d]\n" % whiteValue)


		time.sleep(.5)
Esempio n. 2
0
def runExample():

	print("\nSparkFun Proximity Sensor VCN4040 Example 1\n")
	oProx = qwiic_proximity.QwiicProximity()

	if oProx.connected == False:
		print("The Qwiic Proximity device isn't connected to the system. Please check your connection", \
			file=sys.stderr)
		return

	oProx.begin()

	while True:
		proxValue = oProx.get_proximity()
		print("Proximity Value: %d" % proxValue)
		time.sleep(.4)
def runExample():

	print("\nSparkFun Proximity Sensor VCN4040 Example 5\n")
	oProx = qwiic_proximity.QwiicProximity()

	if oProx.connected == False:
		print("The Qwiic Proximity device isn't connected to the system. Please check your connection", \
			file=sys.stderr)
		return

	# begin Setup
	oProx.begin()

	oProx.power_on_ambient()  	# Power Up the ambient sensor

	# Set the integration time for the proximity sensor
	# 1 to 8 is valid
	oProx.prox_integration_time = 8 

	# Set the integration time for the ambient light sensor in milliseconds
	# 80 to 640ms is valid
	oProx.ambient_integration_time = 80

	# If sensor sees more than this, interrupt pin will go low
	oProx.prox_high_threshold = 2000

	# The int pin will stay low until the value goes below the low threshold value
	oProx.prox_low_threshold = 150

	# Enable both 'away' and 'close' interrupts
	oProx.prox_interrupt_type = oProx.VCNL4040_PS_INT_BOTH

	# This causes the int pin to go low every time a reading is outside the thresholds
	# Get a multimeter and probe the INT pin to see this feature in action
	oProx.enable_prox_logic_mode()

	while True:

		proxValue = oProx.proximity
		print("Proximity Value: \t[%5d]" % proxValue)
		
		ambientValue = oProx.ambient
		print("Ambient Value: \t\t[%5d]\n" % ambientValue)


		time.sleep(1)
Esempio n. 4
0
def runExample():

	print("\nSparkFun Proximity Sensor VCN4040 Example 2\n")
	oProx = qwiic_proximity.QwiicProximity()

	if oProx.connected == False:
		print("The Qwiic Proximity device isn't connected to the system. Please check your connection", \
			file=sys.stderr)
		return

	# begin Setup
	oProx.begin()

	oProx.set_led_current(200)
	oProx.set_prox_integration_time(8) # 1 to 8 is valid

  	# Take 8 readings and average them
	startingProxValue=0
	for x in range(8):
		startingProxValue += oProx.get_proximity()

	startingProxValue /= 8

	deltaNeeded = startingProxValue * 0.05 # Look for %5 change
	if deltaNeeded < 5:
		deltaNeeded = 5   # set a min value

	# Begin operation loop
	nothingThere = True

	while True:
		proxValue = oProx.get_proximity()
		print("Proximity Value: %d" % proxValue)

		if proxValue > startingProxValue + deltaNeeded:
			nothingThere = False
			print("\tSomething is there!")

		elif not nothingThere:
			print("\tI don't see anything")

			nothingThere=True

		time.sleep(.4)
def runExample():

    print("\nSparkFun Proximity Sensor VCN4040 Example 3\n")
    oProx = qwiic_proximity.QwiicProximity()

    if oProx.connected == False:
        print("The Qwiic Proximity device isn't connected to the system. Please check your connection", \
         file=sys.stderr)
        return

    # begin Setup
    oProx.begin()

    oProx.power_off_proximity(
    )  # Power down the proximity portion of the sensor
    oProx.power_on_ambient()  # Power Up the ambient sensor

    while True:
        ambientValue = oProx.get_ambient()
        print("Ambient Value: %d" % ambientValue)

        time.sleep(.4)