Skip to content

Instantly share code, notes, and snippets.

@don don/puck-js-ble-button.js
Last active Aug 18, 2017

Embed
What would you like to do?
// 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
You can’t perform that action at this time.