Created
April 14, 2016 15:34
-
-
Save monteslu/ade6f5701b1b8d84c865ec00eeeae7fe to your computer and use it in GitHub Desktop.
Pagenodes flow of WebUSB and a gamepad to make RGB lights blink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"2f8628c2.e692b8","type":"nodebot","z":"10cff070.ef301","name":"","username":"","password":"","boardType":"firmata","serialportName":"","connectionType":"webusb-serial","mqttServer":"","socketServer":"","pubTopic":"","subTopic":"","tcpHost":"","tcpPort":"","sparkId":"","sparkToken":"","beanId":"","impId":"","meshbluServer":"https://meshblu.octoblu.com","uuid":"","token":"","sendUuid":""},{"id":"1b2f064f.b9378a","type":"johnny5","z":"10cff070.ef301","name":"","func":"var r = new five.Pin(9);\nvar g = new five.Pin(11);\nvar b = new five.Pin(10);\n\nvar buttonState;\n\nnode.on('input', function(msg){\n if(msg.payload && msg.payload.buttons){\n var buttons = msg.payload.buttons;\n var updated = !_.isEqual(buttons, buttonState);\n buttonState = buttons;\n if(updated){\n \n if(buttons[9].pressed){\n r.high();\n }\n else{\n r.low();\n }\n \n if(buttons[1].pressed){\n g.high();\n }\n else{\n g.low();\n }\n \n if(buttons[2].pressed){\n b.high();\n }\n else{\n b.low();\n }\n }\n } \n});","board":"2f8628c2.e692b8","noerr":0,"x":363.69229888916016,"y":461.0769205093384,"wires":[[]]},{"id":"5ef0794f.8230b8","type":"gamepad","z":"10cff070.ef301","name":"","controllerId":"0","refreshInterval":"40","x":144,"y":381,"wires":[["1b2f064f.b9378a"]]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can import this as a flow in https://pagenodes.com