Skip to content

Instantly share code, notes, and snippets.

@paulhayes
Created January 31, 2017 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulhayes/93ee9f27e6b109aadad03cd6bc82160a to your computer and use it in GitHub Desktop.
Save paulhayes/93ee9f27e6b109aadad03cd6bc82160a to your computer and use it in GitHub Desktop.
#include <PinChangeInt.h>
#define BTN 0
int lastRead;
void setup() {
BeanHid.enable();
Bean.setBeanName("Reset Button");
Bean.setPairingPin(162258);
Bean.enablePairingPin(true);
pinMode(BTN, INPUT_PULLUP );
attachPinChangeInterrupt(BTN, pinChanged, CHANGE );
Bean.setLed(0,64,0);
delay(1000);
Bean.setLed(0,0,64);
delay(1000);
Bean.setLed(64,0,0);
delay(1000);
Bean.setLed(0,0,0);
}
void loop() {
int readBtn = digitalRead(BTN);
if( readBtn == LOW && lastRead == HIGH ){
Bean.setLed( 64 , 0, 0);
BeanHid.sendKeys("s");
delay(20);
}
lastRead = readBtn;
Bean.setLed( 0 , 0, 0);
Bean.sleep(0xFFFFFFFF);
}
void pinChanged(void) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment