
import time
import datetime
import RPi.GPIO as GPIO



def __init__(self, pin):

if __name__ == "__main__":
	GPIO.setmode(GPIO.BOARD)
	GPIO.setup(12, GPIO.IN)


def flowing():
	count = 0
	realtime = time.time()
	prevtime = time.time()

	while True:
		prevtest = GPIO.input(12)
		time.sleep(.01)
		test = GPIO.input(12)

		if (test == 0 and prevtest == 1) or (test == 1 and prevtest == 0):
			count += 1
			prevtime = time.time()
			realtime = time.time()
		else:
			realtime = time.time()

		tdelta = realtime - prevtime
		if tdelta > 2 and count > 1:
			break

	return count
@@ -47,18 +47,42 @@
 s GPIO%0A%0A
+class FlowmeterValve():
 %0A%0A
+%09
 def __in
@@ -102,36 +102,27 @@
 n):%0A
-%0Aif __name__ == %22__main__%22:%0A
+%09%09self._pin = pin%0A%09
 %09GPI
@@ -143,16 +143,17 @@
 .BOARD)%0A
+%09
 %09GPIO.se
@@ -156,18 +156,19 @@
 O.setup(
-12
+pin
 , GPIO.I
@@ -184,16 +184,20 @@
 flowing(
+self
 ):%0A%09coun
@@ -288,18 +288,25 @@
 O.input(
-12
+self._pin
 )%0A%09%09time
@@ -341,10 +341,17 @@
 put(
-12
+self._pin
 )%0A%0A%09

add functionality for portability, extrapolation, and structure optimization