mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 17:30:01 +03:00
33 lines
753 B
Java
33 lines
753 B
Java
/*
|
|
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
*
|
|
* 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.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
public class Water_Example {
|
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
// ! [Interesting]
|
|
// Instantiate a Water sensor on digital pin D2
|
|
upm_water.Water water = new upm_water.Water(2);
|
|
|
|
while (true) {
|
|
boolean val = water.isWet();
|
|
if (val) {
|
|
System.out.println("Sensor is wet");
|
|
} else {
|
|
System.out.println("Sensor is dry");
|
|
}
|
|
|
|
Thread.sleep(1000);
|
|
}
|
|
// ! [Interesting]
|
|
}
|
|
|
|
}
|