I am trying to get the Pi4J library to work on my Raspberry Pi 4. I just wrote a simple blink program. It is not toggling the pin as it should be.
Here is the simple program. I have compiled it, and it compiles fine and runs showing the state of the pin, logically. However, the pin is not going high when hooked up to a multimeter.
I am wondering if there is some system setting that is blocking the control of the GPIO pins from this library.
A little bit of info ... I am running Raspberry Pi OS full version. I am fully upgraded and updated. I am using Java 11. And I downloaded the latest Pi4J library as of last week.
public class GPIOTest {
public static void main (String[] args) {
Context pi4j = Pi4J.newAutoContext();
DigitalOutput dirLeft = pi4j.dout().create(14);
System.out.println(pi4j.getClass().toString());
System.out.println(dirLeft.getClass().toString());
while (true){
System.out.println("Setting pin low.");
dirLeft.low();
System.out.println(dirLeft.state());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// Do nothing.
}
System.out.println("Setting pin high.");
dirLeft.high();
System.out.println(dirLeft.state());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// Do nothing.
}
}
}
}