2016-09-14 13:14:18 -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 13:14:18 -07:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2016-09-14 13:14:18 -07:00
|
|
|
*/
|
|
|
|
|
|
2018-02-27 12:12:09 -08:00
|
|
|
public class LineFinder_Example {
|
2016-09-14 13:14:18 -07:00
|
|
|
|
|
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
|
|
|
// ! [Interesting]
|
|
|
|
|
// Instantiate a Line Finder sensor on digital pin D2
|
|
|
|
|
upm_linefinder.LineFinder finder = new upm_linefinder.LineFinder(2);
|
|
|
|
|
// check every second for the presence of white detection
|
|
|
|
|
while (true) {
|
|
|
|
|
boolean val = finder.whiteDetected();
|
|
|
|
|
if (val) {
|
|
|
|
|
System.out.println("White detected");
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("Black detected");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
// ! [Interesting]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|