from gpiozero import Button import time rainCount = 0 bucketSize = 0.2794 # size of bucket in ml rain = Button(6) # setup GPIO 6 as a button # every tip add 1 to count def tipped(): global rainCount rainCount +=1 print (rainCount * bucketSize) def resetRainfall(): global rainCount rainCount = 0 rain.when_pressed = tipped """ # test loop while True: rain.when_pressed = tipped time.sleep(1) """