Package com.pi4j.io.gpio

Examples of com.pi4j.io.gpio.GpioPinDigitalInput


        final GpioPinDigitalOutput run_pin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, "LEDrun", PinState.LOW);
     
       
       
         // provision gpio pin #02 as an input pin with its internal pull down resistor enabled
        final GpioPinDigitalInput exitButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_07, PinPullResistance.PULL_DOWN);

         // provision gpio pin #02 as an input pin with its internal pull down resistor enabled
        final GpioPinDigitalInput myButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02, PinPullResistance.PULL_DOWN);

         // provision gpio pin #00 as an input pin with its internal pull down resistor enabled
        final GpioPinDigitalInput myButton2 = gpio.provisionDigitalInputPin(RaspiPin.GPIO_00, PinPullResistance.PULL_DOWN);
  
         // provision gpio pin #03 as an input pin with its internal pull down resistor enabled
        final GpioPinDigitalInput myButton3 = gpio.provisionDigitalInputPin(RaspiPin.GPIO_03, PinPullResistance.PULL_DOWN);
  
       
            // create and register gpio pin listener
        myButton2.addListener(new GpioPinListenerDigital() {

            @Override
            public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
        
               
            
               
               
                 if(event.getState() == PinState.LOW)
                 {
               
                    
                    System.out.println(ANSI_WHITE +"Velocity  Test Start" + ANSI_GREEN);
                          try {
                              Thread.sleep(1000);
                          } catch (InterruptedException ex) {
                              Logger.getLogger(SerialCommn.class.getName()).log(Level.SEVERE, null, ex);
                          }
                   
                  
                   
                   
                   //  System.out.println("Velocity");
                     hs.store("Test",fm.getSeial());
                        System.out.println(ANSI_WHITE + "000.000mps" + ANSI_GREEN);
                }
                   
                 }
           
          
           
        });
       
        // create and register gpio pin listener
        myButton.addListener(new GpioPinListenerDigital() {
           
           
            @Override
            public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
                // display pin state on console
                long start=0,stop=0;
                
               
               if(event.getState() == PinState.LOW)
               {
               
               if(CheckInternet.testInet("192.168.1.5"))
                {
                
                  String m = fm.getAddr();
                   String ser= fm.getSeial();
                   //System.out.println(ser);
                   //System.out.println(m);
                   System.out.println(ANSI_PURPLE +"Register  Online");
                  
                   try {
                       Thread.sleep(1000);
                   } catch (InterruptedException ex) {
                       Logger.getLogger(SerialCommn.class.getName()).log(Level.SEVERE, null, ex);
                   }
                  
                   //System.out.println("Online...");
                 
                   RegisterDevice reg = new RegisterDevice();
                    String s = reg.sendRecord(m +","+ ser);
                   if(s.equals("false"))
                   {
                       System.out.println(ANSI_BLUE +"Device    Registered" + ANSI_GREEN);
                      // System.out.println("Registered");
                      
                   }
                   else
                   {
                     
                       System.out.println(ANSI_RED +"Already   Registered" + ANSI_GREEN);
                      
                      // System.out.println("Registered");
                  
                   }
               //    System.out.println("");

                }
                    else
                    {
                         System.out.println(ANSI_RED +"Network    Failure");
      
                    }
               }
               
               
               
            }

      
           
        });
       
          
       
       
            // create and register gpio pin listener
        myButton3.addListener(new GpioPinListenerDigital() {

            @Override
            public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {

          if(event.getState() == PinState.LOW)           
View Full Code Here


    }
   
    @Override
    public GpioPinDigitalInput provisionDigitalInputPin(GpioProvider provider, Pin pin, String name, PinPullResistance resistance) {
        // create new GPIO pin instance
        GpioPinDigitalInput gpioPin = provisionDigitalInputPin(provider, pin, name);

        // set the gpio pull resistor
        if (resistance != null) {
            gpioPin.setPullResistance(resistance);
        }
        // return new new pin instance
        return gpioPin;
    }
View Full Code Here

TOP

Related Classes of com.pi4j.io.gpio.GpioPinDigitalInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.