def convert_to_ml():
    print("Flow sensor online!")

    flowrate_mL = []
    time = 0
    while True:
        reading = float(arduinoDigitalRead(2))
        try:
            if reading > 0:
                flowrate_mL.append(reading * 1000 / 60)
                time += 1
                print(flowrate_mL[-1], time)
                sleep(1)
            elif reading <= 0:
                print(0, time)
                sleep(1)

        except KeyboardInterrupt:
            break
    cls()
    print("Flow sensor offline, here are the results.")
    liquid_amount = (float(sum(flowrate_mL) / len(flowrate_mL))) * float(time)
    return liquid_amount
示例#2
0
def buttonpress():
    b = arduinoDigitalRead(2)
    return b
示例#3
0
def buttonpress():              #This function checks to see if the button has pressed
    b = arduinoDigitalRead(2)
    return b