Closed amastrobera closed 3 years ago
@savageautomate and @mrdanimal does this have anything to do with wiringpi being deprecated ?
Closed.
import com.pi4j.wiringpi;
is just the package name. You need to import the actual class you want to use or import all classes from the package using import com.pi4j.wiringpi.*;
...
The following works for me:
import com.pi4j.wiringpi.Gpio;
public class Test {
public static void main(String[] args) throws Exception {
if (Gpio.wiringPiSetup() == -1) {
System.out.println(" ==>> GPIO SETUP FAILED");
throw new Exception("Gpio.wiringPiSetup() failed");
}
System.out.println("<--Pi4J--> GPIO Control Example ... started.");
Gpio.piBoardRev();
Gpio.pinMode(7, Gpio.OUTPUT);
Gpio.pinMode(11, Gpio.OUTPUT);
Gpio.pinMode(13, Gpio.OUTPUT);
Gpio.pinMode(15, Gpio.OUTPUT);
System.out.println(" > backward");
Gpio.digitalWrite(7, Gpio.HIGH);
Gpio.digitalWrite(11, Gpio.LOW);
Gpio.digitalWrite(13, Gpio.HIGH);
Gpio.digitalWrite(15, Gpio.LOW);
// bla bla bla some more code
}
}
Dear Pi4J,
thanks for your library. I had tried the python gpio before, but I have to make the same thing in Java now. I cannot compile the code when using
wiringpi
module. can you help me build it?My code (Test.java)
Structure of my project main_dir
I have downloaded the
jar
files into a lib folder aside the test/Test.java, so I compile it like this (I also compile other stuff depending on jar files this way, and works ... but not wiringpi)Error :