• This code that makes a couple of puck.js devices blink
    the red LED in a heart-beat sequence if they sense each other on a BLE scan.
    The blink rate increases the stronger the signal is (perfect as his/hers blings).

    Button activates/deactivates scan and blink functionality (in order to save battery).
    Even when deactivated it doesn't stop advertising BLE (and other device, if active,
    can sense it). Note, however, that if you connect to a device (for example via the web IDE),
    the other device won't sense it (this is a very common face-palm situation).

    As feedback, the device performs a few heart beat animations (regardless of whether or not
    it senses the other device):

    • When activating, animation rate is slow.
    • When deactivating, animation rate is fast.

    Initial state of the device (after uploading code) is inactive.

    You can do a save() from IDE in that state (no need for onInit() or such, because button would activate whatever needs activating).

    Enjoy.


    1 Attachment

About

Avatar for TheDod @TheDod started