使用cd4021b在java中的ShiftIN操作

时间:2015-01-22 07:22:34

标签: java arduino raspberry-pi microcontroller

我正在尝试使用带有覆盆子pi b +的cd4021b进行shiftin操作,我尝试在谷歌浏览,但我无法得到我的问题的快速答案。下面是我试图在我的raspberrypi中运行的代码。我没有得到shiftin输出到它始终打印0的switchVar1变量。任何人都可以排序这个问题吗?

public static void main(String[] args) throws InterruptedException {

        byte switchVar1;
        final GpioController gpio = GpioFactory.getInstance();
        final GpioPinDigitalOutput latchPin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01, "MyLatch", PinState.HIGH);
        gpio.provisionDigitalInputPin(RaspiPin.GPIO_04, "MyData");
        gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06, "MyClock");        
        for(int n=0;n<=200;n++)
        {
            Thread.sleep(500);
            latchPin.high();
            Thread.sleep(20);
            latchPin.low(); 
            switchVar1 = Shift.shiftIn((byte) 4, (byte) 6, (byte)Shift.MSBFIRST);    
            System.out.println("switchVar1 " + switchVar1);
        }
 }

0 个答案:

没有答案