pi4j按钮监听器与servlet或Java Web应用程序

时间:2014-07-04 14:15:25

标签: java java-ee servlets listener raspberry-pi

我正在使用pi4j来控制树莓派,所以这个例子就是这样,

final GpioPinDigitalInput myButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02,PinPullResistance.PULL_DOWN);

    // create and register gpio pin listener
    myButton.addListener(new GpioPinListenerDigital() {
        @Override
        public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
            // display pin state on console
            System.out.println(" --> GPIO PIN STATE CHANGE: " + event.getPin() + " = " + event.getState());
        }

    });

它适用于java se app但我想在java webapp中使用这个监听器, 我该如何实现这个按钮监听器,实际上是否可能?

感谢,

0 个答案:

没有答案