in the a project, a NOIR pi camera and work it by java and eclipse true. and need to turn on IR-LED when camera is start to preview. so use pi4j in a new class for turn on and turn off LED. but when call it the pi4j class in source of camera panel, then camera not started. what is the problem
pi4j Class:
import com.pi4j.io.gpio.*;
public class gpio_prg {
private static GpioPinDigitalOutput pin;
private GpioController gpio;
public void out(int bcmn, boolean state){
System.out.println("gpio controler");
gpio = GpioFactory.getInstance();
if(bcmn == 29){
if(state){
System.out.println("gpio pin");
pin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_29, "MyLED", PinState.HIGH);
pin.setShutdownOptions(true, PinState.LOW);
System.out.println("--> GPIO NOIR LED state should be: ON");
}else{
pin.low();
System.out.println("--> GPIO NOIR LED state should be: OFF");
}
}
}
error:
wiringPiSetup: Must be root. (Did you forget sudo?)
The problem was solved with python source:
changed java class to:
and
noirLedControl.py
:so now problem is about java class return
reader.readline()
null. and led power on and off not worked, butpython /home/pi/noirLedControl.py
currently run in terminal. my java lib version is "1.8.0_122-ea", so i run my project by two java SE 1.8 and 1.7 and problem not solved. and os is debian 8 every one know what is problem?