You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • 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!


Avatar for Gordon @Gordon started