Skip to content

Instantly share code, notes, and snippets.

@don
Last active August 18, 2017 18:12
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 don/0dbd6066fb3456d13951d8dfeb7eb234 to your computer and use it in GitHub Desktop.
Save don/0dbd6066fb3456d13951d8dfeb7eb234 to your computer and use it in GitHub Desktop.
// Port Arduino BLE button demo to Puck-js
// https://github.com/don/ITP-BluetoothLE/blob/master/arduino/Button_v2/Button_v2.ino
NRF.setServices({
0xFFE0 : {
0xFFE1 : {
value: 0,
readable: true,
notify: true
}
}
}, { advertise: [ 'FFE0' ] });
function notify(value) {
NRF.updateServices({
0xFFE0 : {
0xFFE1 : {
value: value,
notify: true
}
}
});
}
setWatch(function() {
console.log("Pressed");
notify(1);
}, BTN, {edge:"rising", debounce:50, repeat:true});
setWatch(function() {
console.log("Released");
notify(0);
}, BTN, {edge:"falling", debounce:50, repeat:true});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment