Please post what you're working on!

Posted on
of 7
/ 7
Last Next
  • Everyone's starting to get their Pucks now, and they're looking for fun things to do - please post up what you've been working on, however big or small!

    There are two main tutorials that I reckon will help everyone get some fun projects going:

    And if you have a link to a Web Bluetooth on that people can try out on their Pucks, that'd be amazing!

  • Here are two simple pages that I did before:

    It's very easy to just view-source on them and see what's going on...

  • I've got this - "Are you pucker?" an "are you human" verification check.

    Struck me that this sort of tech could do two factor auth of sorts, even though here I'm just checking for humans, it could be ideal for a highly secretive forum dedicated to Puck owners ;)­cker/

    Very unfinished but the comms with Puck work. At least for me. You can grasp the idea.

    It's hosted on Github, so as HTML and JS it's totally hackable I expect, but someone could make this more secure going serverside I imagine.

    Horrid code is down to me editing it in place on github. Seemed easiest when I started out :/

  • Wow, nice! I guess if you wanted to use this for something personal, you could store a secret 'key' on the Puck itself that modified the code sent to it. I guess you'd still need something server-side though.

  • Thanks Gordon. I've tidied it up and finished it. Correct sequence enables the form submission. Has to use GET being Github pages - POST not supported. Hope it's useful to people.

  • I'm making a compass, with an LED that indicates when you're facing north

  • I'm pretty new to coding in general, so please excuse me if I have missed something obvious.

    I am able to turn each of the LEDs on and off using a webpage:


    <button onclick="Puck.write('LED1.set();\n');">o­n</button>
    <button onclick="Puck.write('LED1.reset();\n');"­>off</button>


    <button onclick="Puck.write('LED2.set();\n');">o­n</button>
    <button onclick="Puck.write('LED2.reset();\n');"­>off</button>


    <button onclick="Puck.write('LED3.set();\n');">o­n</button>
    <button onclick="Puck.write('LED3.reset();\n');"­>off</button>

    Nifty. I assume that using PWM or some other technique, I could pass RGB values to the Puck and get any color to display. I built the webpage and have sliders doing all kinds of fancy stuff... but I can't figure out how to send the RBG values to the Puck.

    In other words, instead of on/off, how do I send rgb(80, 128, 199) (which is #50DAC7) to the three LEDs?

    I think that this and this are moving me in the right direction, but I am not a coder and thus can't figure out how to apply it to my problem.

    For anyone curious, what I have so far is attached. Comments are welcome!

    6 Attachments

  • Yes, I think var led = require("RGBLed").connect([LED1, LED2, LED3], false) would work - however as that's using an external module you'd have to connect to the Puck with the Web IDE and upload the code that way (rather than using Web Bluetooth like you are), as then the Web IDE can upload the module for you.

    However if you wanted to access stuff directly (rather than using that module) then the second link you posted would work great. I just posted an update on that thread - the problem reported there was fixed in the 1v90 firmware.

    So, if you're using an up to date firmware, you can modify your code to do:

    <button onclick="Puck.write('analogWrite(LED1,0.­1);analogWrite(LED2,0.2);analogWrite(LED­3,0.3);\n');">blueish</button>

    You just need to make sure that you tweak the 3 numbers in that string to be what you want - they range between 0 and 1.

    Just to add: When you're using PWM and lighting LEDs it'll be running the battery down quite a bit (probably 100x faster than it does when it's idle). It's probably worth adding a button that does Puck.write('LED1.reset();LED2.reset();LE­D3.reset();\n'); so you can stick the Puck back into a state where it's not using much power when you're finished.

    Hope that helps!

  • I'm giving my parents a Qigong button for Christmas. They perform Qigong every morning, by playing an MP3 file of an old Chinese sage offering instructions in Engrish with traditional Chinese music in the background. They just play the MP3 file on their mobile phones, which takes a while to get set up, and sounds horrible.

    My gift will be a Puck with the Yin/Yang symbol painted on it. When they press the button, it will (hopefully) connect to my dad's Mac and play the MP3 file over our living room speakers. I'm thinking of using Node and noble on the Mac to receive the signal and play the MP3 file.

    Should be a fun project and a nice gift :)

  • @Joakim Sounds like a cool project. I'd thought about doing something similar, though more of a soundboard-type project for work. Hadn't heard of noble before. Will check that out.

  • @benddennis You should check out as well, looks like a nice set of audio utilities for Node.

    I love how such a simple interface as a button can open up for so many interesting ideas. Must be really cool to use Puck.js if you're just getting started with programming, it's a magic button! It's of course just as much fun for those of us who like to create interesting stuff with code :)

    (Edit: Moved the rest of my comment a new post in Projects as it got quite long..)

  • @Joakim I tweaked your code to create a Seinfeld clip randomizer as a PoC. Works as expected.

  • A color changing night light I made for my daughter:­htlight.

    We found that the night light looks best when the silicon cover is removed and then just set on top of the Puck in order to better diffuse the light from the LEDs. This makes turning the night light on and off a little bit more difficult, so I will update the project soon with code for using a second Puck as a remote control.

  • @thedamos - have you seen this­297639 ? It makes the LEDs dimmer but gives a lovely diffused glow. Also difficult to turn on and off though...


  • I built a reaction game for the Puck. Each turn you have to beat the fastest reaction time. After turning on, a random amount of time will pass, then a blue LED will flash. Click the button as fast as possible. Green LED indicates a new fastest time. Another click starts a new turn. Gets quite addictive! Fastest time can be reset by holding the button down for 3 seconds.

    » Reaction

  • @benddennis Hehe nice!

    My node version is done. noble worked great, although it's not the easiest of APIs. Maybe my code can be of use to someone looking to try something similar.

    @Fisu The reaction game was just as addictive as you said! Nice one :)

    By the way, I can recommend Netlify for hosting Web Bluetooth Puck projects with HTTPS, as an alternative to GitHub Pages. It's free and easy to connect to git repositories on GitHub/GitLab/Bitbucket/etc. Just git push, wait a few seconds, and it's live. It also supports uploading of files.

  • @Fisu Nice! I've tried it.

  • Hey,
    I came up with the reaction game in tree levels:­eaction/
    Check it out, give feedback and improve!
    Have fun!

  • @Tobi great variations on the game! The double-click in the advanced game is a really interesting twist. I seem to get faster times when the LED remains on, compared to my game where the LED flashes.

  • @Tobi and @Fisu, soon you need an external, replaceable button... the one in the puck will not be able to withstand die-hard, addicted players... ;-)

  • @Fisu: about being faster - I subtract the debounce time in the reaction time calculation, this makes you faster.

    @allObjects: could be true, I added how to use an external button in my README:­eaction/ - this will it easier for you to see the color ;)

  • For anyone who is interested, I've updated my night light project to support a second puck as a remote control:­htlight.

    I started to work on adding support for automatic night light activation based on low ambient light, but have had some problems with some funky reading from my Puck after the LEDs have been turned on and off again.

    Once I have that figured out, I have a few other more advanced project ideas I will post here once they come to fruition :).

  • @thedamos, I noticed the funky light readings as well after running LEDs.

    I wrote a Morse Code interpreter on top of a light change detector detecting ONs and OFFs of short and long pulses of light shined at the puck. To show that the interpreter is active, I blinked the RED led every few seconds and that mis-triggered the ON/OFF detection... :/

    I'm sure you came across this conversation about DvDtDetector for detecting sudden value changes for switching/triggering (on Puck: Light Intensity Changes) which also shows a cross development approach in HTML5 document and browser to avoid the slowing down and battery consuming upload of code after every change... ;)

    For a detail, I had puck uncovered / not covered with the silicon cap. I tried with different LEDs, but depending on the amount of ambient light, it still mis-triggered. A different or modified cap could help with the sensing part somehow shielded from the impact of the LEDs without narrowing detection angle not too much. I though do not know which part does the light detection. Is it the IR LED/part that has a built in detection?... because it uses two (2) pins of the BLE module. Putting a tube / straw on it that protrudes the cap and has a lens at the other end could work. For lens a (half) glass perl (half way pushed in) could do the light catching. The tube should reflect light on the inside wall but not let light through the wall. A metal tube or or kind of tube with aluminum foil inside should work to provide enough dynamics in light intensity guided to the detector.

  • @allObjects @thedamos
    Sad to hear about the light sensor readings after blinking a LED - I intended to fake a proximity sensor by detecting light while still keeping the ability for signalling with LEDs.

    I think the problem could be related to the fact that the light sensor is (in? on?) the red LED, according to the reference:­k_light:

    Read a light value based on the light the red LED is seeing

    I'll post my projects soon - I'm working on a module for using the Puck as an interface: a scroll wheel, e.g. to control volume through BLE HID (works already), and a simple API to control the LEDs, e.g.:


    This mostly works too, but I'm seeing some strange bugs related to the event emitter that I haven't cracked yet.

  • @allObjects @Ron

    My guess is that the sensor works as described in this article by measuring current induced by the photodiode when exposed to light. From that article:

    As a photodiode, an LED is sensitive to wavelengths equal to or
    shorter than the predominant wavelength it emits.

    That would explain the choice of the red LED - it detects more of the spectrum than the other LEDs. The article also notes the following:

    To use the LED as an optical detector, do not forward bias the LED
    into quadrant #1 of the current-voltage (I-V) curve. (Quadrant 1 is
    when the operating voltage and current are both positive.)

    So, there you go. Don't turn it on.

    For the simple night light project, I ended up using a second Puck as the ambient light sensor to turn the puck acting as the night light on and off. This is a decent work-around but certainly could be less than ideal for many projects.

    It is unfortunate that maintaining accurate light sensor readings looks like it requires sacrificing physical feedback on the puck, at least using whats on board. One possible solution in some situations could be to use the load function, which restarts the puck and reloads the script from flash. According to the docs load() does not perform a full hardware reset, but it might reset the light sensor readings.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Please post what you're working on!

Posted by Avatar for Gordon @Gordon