pi@raspberrypi ~/src/java $ wget http://get.pi4j.com/download/pi4j-1.0.deb --2015-06-08 11:35:02-- http://get.pi4j.com/download/pi4j-1.0.deb Resolving get.pi4j.com (get.pi4j.com)... 54.231.18.148 Connecting to get.pi4j.com (get.pi4j.com)|54.231.18.148|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 616120 (602K) [application/octet-stream] Saving to: `pi4j-1.0.deb'
100%[======================================>] 616,120 255K/s in 2.4s
2015-06-08 11:35:05 (255 KB/s) - `pi4j-1.0.deb' saved [616120/616120]
pi@raspberrypi ~/src/java $ sudo dpkg -i pi4j-1.0.deb Selecting previously unselected package pi4j. (데이터베이스 읽는중 ...현재 77870개의 파일과 디렉터리가 설치되어 있습니다.) pi4j 패키지를 푸는 중입니다 (pi4j-1.0.deb에서) ... pi4j (1.0) 설정하는 중입니다 ...
pi@raspberrypi ~/src/java $ sudo apt-get install pi4j 패키지 목록을 읽는 중입니다... 완료 의존성 트리를 만드는 중입니다 상태 정보를 읽는 중입니다... 완료 pi4j 패키지는 이미 최신 버전입니다. 0개 업그레이드, 0개 새로 설치, 0개 제거 및 3개 업그레이드 안 함.
pi@raspberrypi ~/src/java $ ls -al /opt/pi4j/lib 합계 496 drwxr-xr-x 2 root root 4096 6월 8 11:35 . drwxr-xr-x 5 root root 4096 6월 8 11:35 .. -rw-r--r-- 1 root root 179187 4월 18 16:02 pi4j-core.jar -rw-r--r-- 1 root root 217311 4월 18 16:02 pi4j-device.jar -rw-r--r-- 1 root root 74078 4월 18 16:02 pi4j-gpio-extension.jar -rw-r--r-- 1 root root 17663 4월 18 16:02 pi4j-service.jar
pi@raspberrypi ~/src/java $ vi TriggerGpio.java
import java.util.concurrent.Callable;
import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioFactory; import com.pi4j.io.gpio.GpioPinDigitalInput; import com.pi4j.io.gpio.GpioPinDigitalOutput; import com.pi4j.io.gpio.PinPullResistance; import com.pi4j.io.gpio.PinState; import com.pi4j.io.gpio.RaspiPin; import com.pi4j.io.gpio.trigger.GpioCallbackTrigger; import com.pi4j.io.gpio.trigger.GpioPulseStateTrigger; import com.pi4j.io.gpio.trigger.GpioSetStateTrigger; import com.pi4j.io.gpio.trigger.GpioSyncStateTrigger;
public class TriggerGpio {
public static void main(String[] args) throws InterruptedException {
System.out.println("START");
// create gpio controller final GpioController gpio = GpioFactory.getInstance();
// provision gpio pin #02 as an input pin with its internal pull down resistor enabled final GpioPinDigitalOutput ledPin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_07, PinState.LOW);
ledPin.setState(PinState.HIGH);
} }
pi@raspberrypi ~/src/java $ date;javac -classpath .:classes:/opt/pi4j/lib/'*' TriggerGpio.java ;date 2015. 06. 08. (월) 11:40:03 UTC 2015. 06. 08. (월) 11:40:09 UTC
pi@raspberrypi ~/src/java $ sudo java -classpath .:classes:/opt/pi4j/lib/'*' TriggerGpio START |