Puck.JS Torch
Example of a (small) torch with Puck.JS
Explanation about (111).toString(10)
This converts a binary number to a string. 111 says all three led lights should turn on.
var onoff = false;
setWatch(function() {
console.log("Pressed");
setTimeout( () => {
onoff = !onoff;
if(onoff) {
digitalWrite([LED3,LED2,LED1], (111).toString(10));
} else {
digitalWrite([LED3,LED2,LED1], 0);
}
}, 1);
}, BTN, {edge:"rising", debounce:50, repeat:true});
Explanation about (111).toString(10)
This converts a binary number to a string. 111 says all three led lights should turn on.
- 1 (or 001) for red
- 10 (or 010) for green
- and 100 for blue
Reacties
Een reactie posten