Skip to content

Instantly share code, notes, and snippets.

@suru-dissanaike
Created January 25, 2019 16:10
Show Gist options
  • Save suru-dissanaike/f241ce9318a3d5ad7f9d777069d85154 to your computer and use it in GitHub Desktop.
Save suru-dissanaike/f241ce9318a3d5ad7f9d777069d85154 to your computer and use it in GitHub Desktop.
BLE pushbutton with counter
var blueLEDOn = false;
var pushbuttonCounter = 0;
setInterval(function () {
blueLEDOn = !blueLEDOn;
LED3.write(blueLEDOn);
}, 1000);
NRF.setAdvertising({}, { manufacturer: 0x0590, manufacturerData: [pushbuttonCounter] });
setWatch(function () {
pushbuttonCounter++;
if (pushbuttonCounter > 255)
pushbuttonCounter = 0;
NRF.setAdvertising({}, { manufacturer: 0x0590, manufacturerData: [pushbuttonCounter] });
}, BTN, { edge: "rising", repeat: 1, debounce: 20 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment