コード例 #1
0
ファイル: grove_flow_read.py プロジェクト: vartana/GrovePi
'''

# USAGE
#
# Connect the Flow meter to Port 2 on the GrovePi. The flow meter only works on that port

# You can send 'run_in_bk=1' as a parameter, e.g. grovepi.flowRead(run_in_bk=1) to run the flow meter code in the background on the GrovePi. This allows you to use other functions such as digitalRead to run with the flow meter read running in the background
#
# the fist byte is 1 for a new value and 0 for old values
# second byte is flow rate in L/hour
#
# Since the flow meter uses interrupts, it is better to disable it once you are done using it
# The flow sensor readings are updated once every 2 seconds on the firmware
import time
import grovepi

import atexit
atexit.register(grovepi.flowDisable())

print "Reading from the Flow meter"
grovepi.flowEnable()
while True:
    try:
        [new_val, flow_val] = grovepi.flowRead()
        if new_val:
            print flow_val
        time.sleep(.5)

    except IOError:
        print("Error")
コード例 #2
0
THE SOFTWARE.
'''

# USAGE
#
# Connect the Flow meter to Port 2 on the GrovePi. The flow meter only works on that port

# You can send 'run_in_bk=1' as a parameter, e.g. grovepi.flowRead(run_in_bk=1) to run the flow meter code in the background on the GrovePi. This allows you to use other functions such as digitalRead to run with the flow meter read running in the background
#
# the fist byte is 1 for a new value and 0 for old values
# second byte is flow rate in L/hour
#
# Since the flow meter uses interrupts, it is better to disable it once you are done using it
# The flow sensor readings are updated once every 2 seconds on the firmware
import time
import grovepi

import atexit
atexit.register(grovepi.flowDisable())

print "Reading from the Flow meter"
while True:
    try:
        [new_val, flow_val] = grovepi.flowRead(run_in_bk=1)
        if new_val:
            print flow_val
        time.sleep(.5)

    except IOError:
        print("Error")
コード例 #3
0
'''

# USAGE
#
# Connect the Flow meter to Port 2 on the GrovePi. The flow meter only works on that port

# You can send 'run_in_bk=1' as a parameter, e.g. grovepi.flowRead(run_in_bk=1) to run the flow meter code in the background on the GrovePi. This allows you to use other functions such as digitalRead to run with the flow meter read running in the background
#
# the fist byte is 1 for a new value and 0 for old values
# second byte is flow rate in L/hour
#
# Since the flow meter uses interrupts, it is better to disable it once you are done using it
# The flow sensor readings are updated once every 2 seconds on the firmware
import time
import grovepi

import atexit
atexit.register(grovepi.flowDisable())

print("Reading from the Flow meter")
grovepi.flowEnable()
while True:
    try:
		[new_val,flow_val] = grovepi.flowRead()
		if new_val:
			print(flow_val)
		time.sleep(.5) 

    except IOError:
        print ("Error")
コード例 #4
0
ファイル: grove_flow_read.py プロジェクト: nerginer/GrovePi
THE SOFTWARE.
'''

# USAGE
#
# Connect the Flow meter to Port 2 on the GrovePi. The flow meter only works on that port

# You can send 'run_in_bk=1' as a parameter, e.g. grovepi.flowRead(run_in_bk=1) to run the flow meter code in the background on the GrovePi. This allows you to use other functions such as digitalRead to run with the flow meter read running in the background
#
# the fist byte is 1 for a new value and 0 for old values
# second byte is flow rate in L/hour
#
# Since the flow meter uses interrupts, it is better to disable it once you are done using it
# The flow sensor readings are updated once every 2 seconds on the firmware
import time
import grovepi

import atexit
atexit.register(grovepi.flowDisable())

print "Reading from the Flow meter"
while True:
    try:
		[new_val,flow_val] = grovepi.flowRead(run_in_bk=1)
		if new_val:
			print flow_val
		time.sleep(.5) 

    except IOError:
        print ("Error")