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?)