Thank you Martin. I have read the document. I have the inputs working, but only after I install evok. Something in the installation of evok that is not mentioned in the document is changing or initializing hardware so that it works with the diozero library. For instance, i2c must be enabled in the operating system before the relays will work; this is not mentioned in the document you refer to.
I have two Pi boot disks: on one I installed evok, on the other I did not. I can run my Java program and see that it is properly detecting the digital input, but only on the system that had evok installed. I am not using evok for anything, but having it installed makes the difference.
The simple program I am testing with:
package testPi;
import com.diozero.api.DigitalInputDevice;
import com.diozero.api.GpioEventTrigger;
import com.diozero.api.GpioPullUpDown;
import com.diozero.util.SleepUtil;
import org.pmw.tinylog.Logger;
public class ButtonTest {
public static void main(String[] args) {
int ThePin = 24;
if (args.length > 0)
ThePin = Integer.parseInt(args[0]);
test(ThePin);
}
public static void test(int pin) {
DigitalInputDevice di = new DigitalInputDevice(pin, GpioPullUpDown.PULL_UP, GpioEventTrigger.BOTH);
for (;;) {
SleepUtil.sleepSeconds(.5);
System.out.printf("%b\n", di.getValue());
}
}
}