Skip to content

Instantly share code, notes, and snippets.

@nkenna
Created June 24, 2018 21:08
Show Gist options
  • Save nkenna/4ccb47076353383542eceeccd52a516e to your computer and use it in GitHub Desktop.
Save nkenna/4ccb47076353383542eceeccd52a516e to your computer and use it in GitHub Desktop.
// monitor for Pin State changes
// if state is high, ON Led
pir.addListener(new GpioPinListenerDigital(){
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event){
System.out.println(event.getState());
// turn led ON if pin attached to PIR sensor is high
if(event.getState().isHigh() ){
ledPin.high();
}else{
ledPin.low();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment