2016-09-14 11:37:08 -07:00
|
|
|
/*
|
|
|
|
|
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2016-09-14 11:37:08 -07:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2016-09-14 11:37:08 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//NOT TESTED!!!
|
2018-02-27 12:12:09 -08:00
|
|
|
public class WFS_Example {
|
2016-09-14 11:37:08 -07:00
|
|
|
|
2017-01-26 15:06:05 -07:00
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
|
|
|
// ! [Interesting]
|
2016-09-14 11:37:08 -07:00
|
|
|
|
2017-01-26 15:06:05 -07:00
|
|
|
// Instantiate a Water Flow Sensor on
|
|
|
|
|
// digital pin D2. This must be an
|
|
|
|
|
// interrupt capable pin.
|
|
|
|
|
upm_wfs.WFS flow = new upm_wfs.WFS(2);
|
2016-09-14 11:37:08 -07:00
|
|
|
|
2017-01-26 15:06:05 -07:00
|
|
|
flow.clearFlowCounter();
|
|
|
|
|
flow.startFlowCounter();
|
2016-09-14 11:37:08 -07:00
|
|
|
|
2017-01-26 15:06:05 -07:00
|
|
|
while (true) {
|
|
|
|
|
System.out.print("Millis: " + flow.getMillis() + " FlowCount: " + flow.flowCounter());
|
|
|
|
|
System.out.println(" Flow Rate: " + flow.flowRate() + " LPM");
|
|
|
|
|
|
|
|
|
|
Thread.sleep(2000);
|
|
|
|
|
}
|
|
|
|
|
// ! [Interesting]
|
|
|
|
|
}
|
2016-09-14 11:37:08 -07:00
|
|
|
}
|