IOT Based Remote Control Platform with XBox 360 Gamepad

The Flow is one half of a control infrastructure for a Remote Tele-Operated Vehicle. It utlises the Node-HID node to extract control data (button press) from an operator using an XBox 360 controller gamepad connected through USB to the host computer running the node-red flow.

The data is processed into a suitable format and sent using an MQTT server hosted by Amazon Web Services IOT thing, to the receiver side node-red flow running on a raspbeery pi embedded on the vehicle; which controls the vehicles' movements and other functions based on the recieved control data. The Json file for the flow is included below.

The flow requires other contributed node-red nodes such as: USBHID; Node-Red Dashboard nodes for the User Interface (UI). Other nodes utlized are standard node-red nodes available on installation

[{"id":"f6a6bc73.5c237","type":"subflow","name":"Loop","info":"","in":[{"x":64,"y":114,"wires":[{"id":"66b0cedb.02966"}]}],"out":[{"x":557,"y":176,"wires":[{"id":"2d027550.10e306","port":0}]}]},{"id":"2d027550.10e306","type":"function","z":"f6a6bc73.5c237","name":"Loop","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n// console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n// context = {};\nconsole.log('Entering loop');\nconsole.log(msg.loop);\n\nif (msg.loop == 'off' ) {\n\treturn [msg,null];\n} else {\n\tconsole.log('Looping');\n\treturn [msg,msg];\n}","outputs":"2","noerr":0,"x":339,"y":244,"wires":[[],["66b0cedb.02966"]]},{"id":"cd581cc2.d8b21","type":"delay","z":"f6a6bc73.5c237","name":"Delay it","pauseType":"queue","timeout":"2","timeoutUnits":"seconds","rate":"2","nbRateUnits":"","rateUnits":"second","randomFirst":"","randomLast":"","randomUnits":"seconds","drop":true,"x":419,"y":114,"wires":[["2d027550.10e306"]]},{"id":"66b0cedb.02966","type":"function","z":"f6a6bc73.5c237","name":"Control Loop","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nmsg.loop = 'on';\n\nreturn msg;","outputs":1,"noerr":0,"x":288,"y":115,"wires":[["cd581cc2.d8b21"]]},{"id":"7c105a82.82074c","type":"subflow","name":"Process HID Data","info":"","in":[{"x":599.5,"y":380.22998046875,"wires":[{"id":"e134a052.332638"}]}],"out":[{"x":1378,"y":25,"wires":[{"id":"1d87a425.7ab38c","port":0}]},{"x":1374,"y":78,"wires":[{"id":"af5d1b83.b4742","port":0}]},{"x":1375,"y":126,"wires":[{"id":"1f177459.1c245","port":0}]},{"x":1421,"y":158,"wires":[{"id":"d573c5e7.6830f8","port":0}]},{"x":1422,"y":209,"wires":[{"id":"64172fb2.77cca","port":0}]},{"x":1420,"y":456,"wires":[{"id":"c0af06d7.a20fc","port":0}]},{"x":1420,"y":500,"wires":[{"id":"7602d735.51369c","port":0}]},{"x":1419,"y":546,"wires":[{"id":"1b708d54.aa2d07","port":0}]},{"x":1415,"y":607,"wires":[{"id":"f286db94.0d7b88","port":0}]},{"x":1423,"y":256,"wires":[{"id":"c5b6a87d.0d34b8","port":0}]},{"x":1470,"y":286,"wires":[{"id":"e4e22393.84c3f","port":0}]},{"x":1425,"y":316,"wires":[{"id":"5f826b96.79b5e4","port":0}]},{"x":1419,"y":361,"wires":[{"id":"21fc9a01.c370e2","port":0}]},{"x":1420,"y":409,"wires":[{"id":"329e903f.f214c","port":0}]}]},{"id":"c4327969.2b63c8","type":"switch","z":"7c105a82.82074c","name":"Switch to Required Function","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"8","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"144","vt":"num"},{"t":"eq","v":"80","vt":"num"},{"t":"eq","v":"128","vt":"num"},{"t":"eq","v":"64","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"32","vt":"num"},{"t":"eq","v":"24","vt":"num"},{"t":"eq","v":"17","vt":"num"},{"t":"eq","v":"20","vt":"num"},{"t":"eq","v":"18","vt":"num"},{"t":"eq","v":"16","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","outputs":16,"x":1033.5,"y":265.22998046875,"wires":[["1d87a425.7ab38c"],["1d87a425.7ab38c"],["af5d1b83.b4742"],["af5d1b83.b4742"],["1f177459.1c245"],["1f177459.1c245"],["d573c5e7.6830f8"],["d573c5e7.6830f8"],["64172fb2.77cca"],["64172fb2.77cca"],["c5b6a87d.0d34b8"],["e4e22393.84c3f"],["5f826b96.79b5e4"],["21fc9a01.c370e2"],["5f826b96.79b5e4","c5b6a87d.0d34b8","e4e22393.84c3f","21fc9a01.c370e2","329e903f.f214c"],["329e903f.f214c"]]},{"id":"e134a052.332638","type":"delay","z":"7c105a82.82074c","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"2","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":774.5,"y":348.22998046875,"wires":[["c755c66b.12d1b"]]},{"id":"c755c66b.12d1b","type":"function","z":"7c105a82.82074c","name":"Process Button Data","func":"var buf = new Buffer.from(msg.payload);\n\n//Extract Required Button Data\nmsg.dgcsk = buf.slice(-4, -3);\nmsg.steer$speed = buf.slice(-3, -2);\n\nvar a = new Buffer.from(msg.dgcsk, 'hex')[0];\nvar b = new Buffer.from(msg.steer$speed, 'hex')[0];\n\nvar msg1 = {payload:a};\nvar msg2 = {payload:b};\nreturn [msg1,msg2,];","outputs":"2","noerr":0,"x":775,"y":398,"wires":[["c4327969.2b63c8"],["afbaf7cf.4fde88"]]},{"id":"1d87a425.7ab38c","type":"function","z":"7c105a82.82074c","name":"Direction","func":"var a = 1;//Reverse Gear\nvar y = 8;//Forward Gear\nvar button = msg.payload;//Output Message\nvar zero = 0;\nif (button == a) \n{var msg = {payload:a.toString()};\n}\nelse if (button == y) \n{var msg = {payload:y.toString()};\n}\nelse {var msg = {payload:zero.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1275.5,"y":26.160003662109375,"wires":[[]]},{"id":"af5d1b83.b4742","type":"function","z":"7c105a82.82074c","name":"Gears","func":"var b = 2;//1st Gear: Low Torque for Flat Terrain\nvar x = 4;//2nd Gear: High Torque for Stairs\nvar button = msg.payload;//Output Message\nvar zero = 0;\nif (button == b) \n{var msg = {payload:b.toString()};\n}\nelse if (button == x) \n{var msg = {payload:x.toString()};\n}\nelse {var msg = {payload:zero.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1284.5,"y":80.16000366210938,"wires":[[]]},{"id":"1f177459.1c245","type":"function","z":"7c105a82.82074c","name":"Clutch","func":"var a = 144;//Clutch Engaged\nvar b = 80;//Clutch Disengaged\nvar button = msg.payload;//Output Message\n\nif (button == a) \n{var msg = {payload:a.toString()};\n}\nelse if (button == b) \n{var msg = {payload:b.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1268.5,"y":128.16000366210938,"wires":[[]]},{"id":"d573c5e7.6830f8","type":"function","z":"7c105a82.82074c","name":"Start/Kill","func":"var start = 128;//Starter Motor\nvar kill = 64;//Kill Switch\nvar button = msg.payload;//Output Message\nvar zero = 0;\nif (button == start) \n{var msg = {payload:start.toString()};\n}\nelse if (button == kill)\n{var msg = {payload:kill.toString()};\n}\nelse {var msg = {payload:zero.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1289.5,"y":169.16000366210938,"wires":[[]]},{"id":"afbaf7cf.4fde88","type":"switch","z":"7c105a82.82074c","name":"Switch to Required Function","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"12","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"28","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"20","vt":"num"}],"checkall":"true","outputs":6,"x":1016,"y":461,"wires":[["c0af06d7.a20fc"],["c0af06d7.a20fc","7602d735.51369c"],["7602d735.51369c"],["1b708d54.aa2d07"],["1b708d54.aa2d07","f286db94.0d7b88"],["f286db94.0d7b88"]]},{"id":"c0af06d7.a20fc","type":"function","z":"7c105a82.82074c","name":"Right","func":"var right = 12;//Right Steer/Brake Right\nvar stop = 0;//Stop Applying Brakes\nvar button = msg.payload;//Input Message\n\nif (button == right) \n{var msg = {topic: 'a', payload:right.toString()};\n}\nelse if (button == stop) \n{var msg = {topic: 'a',payload:stop.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1290.5,"y":454.239990234375,"wires":[[]]},{"id":"64172fb2.77cca","type":"function","z":"7c105a82.82074c","name":"Hand Brakes","func":"var lock = 32;//Lock Brakes\nvar zero = 0;//Release Brakes\nvar button = msg.payload;//Output Message\n\nif (button == lock) \n{var msg = {payload:lock.toString()};\n}\nelse if (button == zero)\n{var msg = {payload:zero.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1309.5,"y":210.760009765625,"wires":[[]]},{"id":"7602d735.51369c","type":"function","z":"7c105a82.82074c","name":"Left","func":"var left = 28;//Left Steer/Brake Left\nvar stop = 0;//Stop Applying Brakes\nvar button = msg.payload;//Input Message\n\nif (button == left)\n{var msg = {topic: 'b', payload:left.toString()};\n}\nelse if (button == stop)\n{var msg = {topic: 'b', payload:stop.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1296.5,"y":498.05999755859375,"wires":[[]]},{"id":"1b708d54.aa2d07","type":"function","z":"7c105a82.82074c","name":"Up","func":"var up = 4;//Open Throttle\nvar stop = 0;//Stop Applying Brakes\nvar button = msg.payload;//Input Message\n\nif (button == up) \n{var msg = {topic: 'a',payload:up.toString()};\n}\nelse if (button == stop) \n{var msg = {topic: 'a',payload:stop.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1309,"y":556,"wires":[[]]},{"id":"f286db94.0d7b88","type":"function","z":"7c105a82.82074c","name":"Down","func":"var down = 20;//Close Throttle\nvar stop = 0;//Stop Applying Brakes\nvar button = msg.payload;//Input Message\n\nif (button == down) \n{var msg = {topic: 'b',payload:down.toString()};\n}\nelse if (button == stop) \n{var msg = {topic: 'b',payload:stop.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1301,"y":610,"wires":[[]]},{"id":"c5b6a87d.0d34b8","type":"function","z":"7c105a82.82074c","name":"Arms Up","func":"var a = 24;//Up\nvar b = 16;//Stop\nvar button = msg.payload;//Output Message\n\nif (button == a) \n{var msg = {topic: 'a', payload:a.toString()};\n}\nelse if (button == b) \n{var msg = {topic: 'a', payload:b.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1307,"y":248,"wires":[[]]},{"id":"e4e22393.84c3f","type":"function","z":"7c105a82.82074c","name":"Arms Down","func":"var a = 17;//Down\nvar b = 16;//Stop\nvar button = msg.payload;//Output Message\n\nif (button == a) \n{var msg = {topic: 'b', payload:a.toString()};\n}\nelse if (button == b) \n{var msg = {topic: 'b', payload:b.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1312,"y":288,"wires":[[]]},{"id":"5f826b96.79b5e4","type":"function","z":"7c105a82.82074c","name":"Arms Pinch","func":"var a = 20;//Pinch\nvar b = 16;//Stop\nvar button = msg.payload;//Output Message\n\nif (button == a) \n{var msg = {topic: 'a', payload:a.toString()};\n}\nelse if (button == b) \n{var msg = {topic: 'a', payload:b.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1316,"y":326,"wires":[[]]},{"id":"21fc9a01.c370e2","type":"function","z":"7c105a82.82074c","name":"Arms Release","func":"var a = 18;//Release\nvar b = 16;//Stop\nvar button = msg.payload;//Output Message\n\nif (button == a) \n{var msg = {topic: 'b', payload:a.toString()};\n}\nelse if (button == b) \n{var msg = {topic: 'b', payload:b.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1328,"y":366,"wires":[[]]},{"id":"329e903f.f214c","type":"function","z":"7c105a82.82074c","name":"Shift","func":"var a = 16;//Shift\nvar b = 0;//Stop\nvar button = msg.payload;//Output Message\n\nif (button == a) \n{var msg = {payload:a.toString()};\n}\nelse if (button == b) \n{var msg = {payload:b.toString()};}\nreturn msg;","outputs":1,"noerr":0,"x":1305,"y":408,"wires":[[]]},{"id":"5bbb6869.248f3c","type":"tab","label":"Control Deck"},{"id":"909124cc.2ec148","type":"mqtt out","z":"5bbb6869.248f3c","name":"Start/Kill","topic":"/TSRV","qos":"0","retain":"","broker":"2fd74cdb.1faa28","x":985,"y":907,"wires":[]},{"id":"4857d06d.334cbc","type":"mqtt out","z":"5bbb6869.248f3c","name":"Direction","topic":"/Direction","qos":"0","retain":"","broker":"2fd74cdb.1faa28","x":974,"y":632,"wires":[]},{"id":"198989f2.a3ea92","type":"mqtt out","z":"5bbb6869.248f3c","name":"Right","topic":"/Right","qos":"0","retain":"","broker":"2fd74cdb.1faa28","x":948,"y":1081,"wires":[]},{"id":"7581fc3f.6a3758","type":"mqtt out","z":"5bbb6869.248f3c","name":"Left","topic":"/Left","qos":"0","retain":"","broker":"2fd74cdb.1faa28","x":943,"y":1134,"wires":[]},{"id":"54aac1d8.27d818","type":"mqtt out","z":"5bbb6869.248f3c","name":"Clutch","topic":"/Clutch","qos":"0","retain":"","broker":"2fd74cdb.1faa28","x":996.5,"y":823.0900268554688,"wires":[]},{"id":"ebd96e71.b6b07","type":"mqtt out","z":"5bbb6869.248f3c","name":"Gear","topic":"/Gear","qos":"","retain":"","broker":"2fd74cdb.1faa28","x":976.5,"y":730.0899658203125,"wires":[]},{"id":"6860fb63.027b34","type":"HIDdevice","z":"5bbb6869.248f3c","connection":"67a0ea4.094d114","name":"HID","x":319,"y":1018,"wires":[["7ef288a.9c8c338"],[]]},{"id":"7ef288a.9c8c338","type":"subflow:7c105a82.82074c","z":"5bbb6869.248f3c","x":470.5,"y":1012.2100067138672,"wires":[["4857d06d.334cbc","12426e5e.481b6e"],["ebd96e71.b6b07","549ceaa2.cd8adc"],["54aac1d8.27d818","bf99f7a.a5de388"],["909124cc.2ec148","6a6c9f2.63c762"],["d7605b8.33021e8","7ecdca29.e90b1c"],["198989f2.a3ea92","7dcdff6.7015e8"],["7581fc3f.6a3758","7dcdff6.7015e8"],["66262be5.e92e88","20f1b17a.a3fae6"],["66262be5.e92e88","a282e5e3.b47ce"],["84d0aaaf.a4a748","b0dbaaef.95a0c8"],["84d0aaaf.a4a748","b0dbaaef.95a0c8"],["7d7e111.565767","61044e19.94c6b8"],["7d7e111.565767","61044e19.94c6b8"],["5de32cca.7c11c8"]]},{"id":"d7605b8.33021e8","type":"mqtt out","z":"5bbb6869.248f3c","name":"Hand Brakes","topic":"/Lock","qos":"","retain":"","broker":"2fd74cdb.1faa28","x":974.5,"y":993.760009765625,"wires":[]},{"id":"20f1b17a.a3fae6","type":"mqtt out","z":"5bbb6869.248f3c","name":"Up","topic":"/Up","qos":"1","retain":"","broker":"2fd74cdb.1faa28","x":970.5,"y":1222.760009765625,"wires":[]},{"id":"df864979.434d","type":"ui_text","z":"5bbb6869.248f3c","group":"6b538893.4d5da","order":0,"width":0,"height":0,"name":"Notification","label":"","format":"{{msg.payload}}","layout":"row-left","x":1288,"y":593.9999694824219,"wires":[]},{"id":"d47a78f9.58c0f8","type":"function","z":"5bbb6869.248f3c","name":"Direction Notification","func":"var a = '1';//Reverse Gear\nvar y = '8';//Forward Gear\n\n\nif (msg.payload == y ) \n{\n    var msg = {payload: \"Forward Gear Selected\"};\n} \nelse if (msg.payload == a) \n{\n    var msg = {payload: \"Reverse Gear Selected\"};\n} \nelse {var msg = {payload: \"Select Direction of Travel\"};}\nreturn msg;\n\n","outputs":"1","noerr":0,"x":1117.5,"y":593.3499755859375,"wires":[["df864979.434d"]]},{"id":"afe22ab7.b618c","type":"function","z":"5bbb6869.248f3c","name":"Gear Notification","func":"var b = '2';//1st Gear\nvar x = '4';//2nd Gear\n\nif (msg.payload == b) \n{\n    var msg = {payload: \"1st Gear Selected\"};\n} \nelse if (msg.payload == x) \n{\n    var msg = {payload: \"2nd Gear Selected\"};\n} \nelse {var msg = {payload: \"Select Required Gear For Travel\"};}\nreturn msg;\n","outputs":1,"noerr":0,"x":1109,"y":687.2099609375,"wires":[["dfdf7051.5641f"]]},{"id":"dfdf7051.5641f","type":"ui_text","z":"5bbb6869.248f3c","group":"6b538893.4d5da","order":0,"width":0,"height":0,"name":"Notification","label":"","format":"{{msg.payload}}","layout":"row-left","x":1267.5,"y":686.6499633789062,"wires":[]},{"id":"411cb97e.9249b8","type":"ui_text","z":"5bbb6869.248f3c","group":"a2d6d106.46c1f8","order":0,"width":0,"height":0,"name":"Notification","label":"","format":"{{msg.payload}}","layout":"row-left","x":1237,"y":781,"wires":[]},{"id":"d0a4ec0e.eb5c5","type":"function","z":"5bbb6869.248f3c","name":"Clutch Status","func":"var a = '144';//Clutch Engaged\nvar b = '80';//Clutch Disengaged\n\nif (msg.payload == a ) \n{\n    var msg = {payload: \"Clutch Engaged\"};\n} \nelse if (msg.payload == b) \n{\n    var msg = {payload: \"Clutch Disengaged\"};\n}\nreturn msg;\n\n","outputs":"1","noerr":0,"x":1096.5,"y":782.3499755859375,"wires":[["411cb97e.9249b8"]]},{"id":"f0e21886.fb54a8","type":"function","z":"5bbb6869.248f3c","name":"S/K","func":"var start = '128';//Starter Motor\nvar kill = '64';//Kill Switch\n\nif (msg.payload == start ) \n{\n    var msg = {payload: \"Start Button Pressed\"};\n} \nelse if (msg.payload == kill) \n{\n    var msg = {payload: \"Kill Switch Pressed\"};\n}else {var msg = {payload: \"Press Start Button to Start Vehicle\"};}\nreturn msg;\n\n","outputs":"1","noerr":0,"x":1075,"y":871.0000305175781,"wires":[["4fc17959.964dd"]]},{"id":"bf6869b0.72281","type":"function","z":"5bbb6869.248f3c","name":"HB","func":"var lock = '32';//Lock Brakes\nvar unlock = '0';//Release Brakes\n\n\nif (msg.payload == lock ) \n{\n    var msg = {payload: \"Lock Brakes Deployed: Vehicle Locked\"};\n} \nelse if (msg.payload == unlock) \n{\n    var msg = {payload: \"Lock Brakes Released\"};\n}\nreturn msg;\n\n","outputs":"1","noerr":0,"x":1075.5,"y":955.3500061035156,"wires":[["692a2980.4ed86"]]},{"id":"4fc17959.964dd","type":"ui_text","z":"5bbb6869.248f3c","group":"8cbd1a60.fdc528","order":0,"width":0,"height":0,"name":"Notification","label":"","format":"{{msg.payload}}","layout":"row-left","x":1195.5,"y":869.6500244140625,"wires":[]},{"id":"692a2980.4ed86","type":"ui_text","z":"5bbb6869.248f3c","group":"8cbd1a60.fdc528","order":0,"width":0,"height":0,"name":"Notification","label":"","format":"{{msg.payload}}","layout":"row-left","x":1195.5,"y":956.6500244140625,"wires":[]},{"id":"7dcdff6.7015e8","type":"function","z":"5bbb6869.248f3c","name":"Steer","func":"var right = '12';//Right Steer/Brake Right\nvar left = '28';//Left Steer/Brake Left\nvar zero = '0';\nvar button = msg.payload;//Output Message\n\ncontext.s = context.s || 0;\ncontext.t = context.t || 0;\n\nif (msg.topic == 'a') \n    {context.s = msg.payload;} \nelse if (msg.topic == 'b') \n    {context.t = msg.payload;}\nif (context.s == right ) \n{\n    var msg = {payload: \"Turning Right\"};\n} \nelse if (context.t == left) \n{\n    var msg = {payload: \"Turning Left\"};\n}\nelse if (context.s == zero && context.t == zero)\n{var msg = {payload: \"Moving Forward\"};}\nreturn msg;\n\n","outputs":"1","noerr":0,"x":943,"y":1042,"wires":[["5e9e4c5d.15fdb"]]},{"id":"5e9e4c5d.15fdb","type":"ui_text","z":"5bbb6869.248f3c","group":"2d16f805.28c4f8","order":0,"width":0,"height":0,"name":"Notification","label":"","format":"{{msg.payload}}","layout":"row-left","x":1063,"y":1041.300048828125,"wires":[]},{"id":"a282e5e3.b47ce","type":"mqtt out","z":"5bbb6869.248f3c","name":"Down","topic":"/Down","qos":"1","retain":"","broker":"2fd74cdb.1faa28","x":761,"y":1334,"wires":[]},{"id":"66262be5.e92e88","type":"function","z":"5bbb6869.248f3c","name":"Throttle","func":"var up = '4';//\nvar down = '20';\nvar zero = '0';\nvar button = msg.payload;//Output Message\n\ncontext.u = context.u || 0;\ncontext.v = context.v || 0;\n\nif (msg.topic == 'a') \n    {context.u = msg.payload;} \nelse if (msg.topic == 'b') \n    {context.v = msg.payload;}\n    \nif (context.u == up ) \n{\n    var msg = {payload: \"Throttle Opening\"};\n} \nelse if (context.v == down) \n{\n    var msg = {payload: \"Throttle Closing\"};\n}\nelse if (context.u == zero && context.v == zero)\n{var msg = {payload: \"Throttle Constant\"};}\nreturn msg;\n\n","outputs":"1","noerr":0,"x":945,"y":1187,"wires":[["93e0b510.429ec8"]]},{"id":"93e0b510.429ec8","type":"ui_text","z":"5bbb6869.248f3c","group":"fafbaca2.4df2d","order":0,"width":0,"height":0,"name":"Notification","label":"","format":"{{msg.payload}}","layout":"row-left","x":1075,"y":1187.300048828125,"wires":[]},{"id":"5486ab2c.20d13c","type":"ui_template","z":"5bbb6869.248f3c","group":"eb7e50e8.3730e","name":"Video Stream","order":1,"width":"17","height":"10","format":"<embed \nsrc=\"https://797b647978.dataplicity.io/?action=stream\"\nwidth=\"880\" height=\"500\">","storeOutMessages":true,"fwdInMessages":true,"x":472,"y":887,"wires":[[]]},{"id":"84d0aaaf.a4a748","type":"mqtt out","z":"5bbb6869.248f3c","name":"Lift/Lower","topic":"/Lift","qos":"0","retain":"","broker":"2fd74cdb.1faa28","x":888.5,"y":1305.449951171875,"wires":[]},{"id":"7d7e111.565767","type":"mqtt out","z":"5bbb6869.248f3c","name":"Pinch/Release","topic":"/PR","qos":"0","retain":"","broker":"2fd74cdb.1faa28","x":780.5,"y":1380.449951171875,"wires":[]},{"id":"5de32cca.7c11c8","type":"mqtt out","z":"5bbb6869.248f3c","name":"Shift","topic":"/Shift","qos":"0","retain":"","broker":"2fd74cdb.1faa28","x":602.5,"y":1321.449951171875,"wires":[]},{"id":"12426e5e.481b6e","type":"subflow:f6a6bc73.5c237","z":"5bbb6869.248f3c","name":"","x":966,"y":593,"wires":[["d47a78f9.58c0f8"]]},{"id":"549ceaa2.cd8adc","type":"subflow:f6a6bc73.5c237","z":"5bbb6869.248f3c","name":"","x":969,"y":686,"wires":[["afe22ab7.b618c"]]},{"id":"bf99f7a.a5de388","type":"subflow:f6a6bc73.5c237","z":"5bbb6869.248f3c","name":"","x":975,"y":783,"wires":[["d0a4ec0e.eb5c5"]]},{"id":"6a6c9f2.63c762","type":"subflow:f6a6bc73.5c237","z":"5bbb6869.248f3c","name":"","x":974,"y":871.77001953125,"wires":[["f0e21886.fb54a8"]]},{"id":"7ecdca29.e90b1c","type":"subflow:f6a6bc73.5c237","z":"5bbb6869.248f3c","name":"","x":976,"y":955.77001953125,"wires":[["bf6869b0.72281"]]},{"id":"b0dbaaef.95a0c8","type":"function","z":"5bbb6869.248f3c","name":"Lift/Lower","func":"var up = '24';//\nvar down = '17';\nvar zero = '16';\nvar button = msg.payload;//Output Message\n\ncontext.w = context.w || 0;\ncontext.z = context.z || 0;\n\nif (msg.topic == 'a') \n    {context.w = msg.payload;} \nelse if (msg.topic == 'b') \n    {context.z = msg.payload;}\n    \nif (context.w == up ) \n{\n    var msg = {payload: \"Lifting Arms\"};\n} \nelse if (context.z == down) \n{\n    var msg = {payload: \"Lowering Arms\"};\n}\nelse if (context.w == zero && context.z == zero)\n{var msg = {payload: \"No Vertical Movement\"};}\nreturn msg;\n\n","outputs":"1","noerr":0,"x":988,"y":1271,"wires":[["e9b7832b.d5f89"]]},{"id":"e9b7832b.d5f89","type":"ui_text","z":"5bbb6869.248f3c","group":"4f25104d.db4644","order":0,"width":0,"height":0,"name":"Notification","label":"","format":"{{msg.payload}}","layout":"row-left","x":1118,"y":1270.300048828125,"wires":[]},{"id":"61044e19.94c6b8","type":"function","z":"5bbb6869.248f3c","name":"P/R","func":"var up = '20';//\nvar down = '18';\nvar zero = '16';\nvar button = msg.payload;//Output Message\n\ncontext.s = context.s || 0;\ncontext.t = context.t || 0;\n\nif (msg.topic == 'a') \n    {context.s = msg.payload;} \nelse if (msg.topic == 'b') \n    {context.t = msg.payload;}\n    \nif (context.s == up ) \n{\n    var msg = {payload: \"Pinching Arms\"};\n} \nelse if (context.t == down) \n{\n    var msg = {payload: \"Releasing Arms\"};\n}\nelse if (context.s == zero && context.t == zero)\n{var msg = {payload: \"No Horizontal Movement\"};}\nreturn msg;\n\n","outputs":"1","noerr":0,"x":954,"y":1384,"wires":[["ca043484.96c938"]]},{"id":"ca043484.96c938","type":"ui_text","z":"5bbb6869.248f3c","group":"512a3b61.4848bc","order":0,"width":0,"height":0,"name":"Notification","label":"","format":"{{msg.payload}}","layout":"row-left","x":1074,"y":1383.300048828125,"wires":[]},{"id":"2fd74cdb.1faa28","type":"mqtt-broker","z":"","broker":"a16ck7fy1v223m.iot.eu-west-1.amazonaws.com/","port":"8883","tls":"940e6b81.c9e6b","clientid":"Super","usetls":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},{"id":"67a0ea4.094d114","type":"HIDConfig","z":"","vid":"1118","pid":"654","name":"Pad"},{"id":"6b538893.4d5da","type":"ui_group","z":"","name":"Gear Selection","tab":"37a781c0.09d132","order":7,"disp":true,"width":"6"},{"id":"a2d6d106.46c1f8","type":"ui_group","z":"","name":"Clutch Status","tab":"37a781c0.09d132","order":1,"disp":true,"width":"6"},{"id":"8cbd1a60.fdc528","type":"ui_group","z":"","name":"Vehicle Status","tab":"37a781c0.09d132","order":8,"disp":true,"width":"6"},{"id":"2d16f805.28c4f8","type":"ui_group","z":"","name":"Steering Status","tab":"37a781c0.09d132","order":2,"disp":true,"width":"6"},{"id":"fafbaca2.4df2d","type":"ui_group","z":"","name":"Cruise Status","tab":"37a781c0.09d132","order":3,"disp":true,"width":"5"},{"id":"eb7e50e8.3730e","type":"ui_group","z":"","name":"TSRV Video Stream","tab":"37a781c0.09d132","order":4,"disp":true,"width":"17"},{"id":"4f25104d.db4644","type":"ui_group","z":"","name":"Vertical Grip Control","tab":"37a781c0.09d132","order":5,"disp":true,"width":"6"},{"id":"512a3b61.4848bc","type":"ui_group","z":"","name":"Horizontal Grip Control","tab":"37a781c0.09d132","order":6,"disp":true,"width":"6"},{"id":"940e6b81.c9e6b","type":"tls-config","z":"","name":"AWS","cert":"C:\\Users\\alakoa\\pi_socket\\TSRV.cert.pem","key":"C:\\Users\\alakoa\\pi_socket\\TSRV.private.key","ca":"C:\\Users\\alakoa\\pi_socket\\root.CA.pem","verifyservercert":true},{"id":"37a781c0.09d132","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]
hafizalk

Flow Info

created 3 months ago

Node Types

Core
  • delay (x2)
  • function (x26)
  • mqtt out (x12)
  • mqtt-broker (x1)
  • switch (x2)
Other
  • HIDConfig (x1)
  • HIDdevice (x1)
  • subflow (x2)
  • subflow:7c105a82.82074c (x1)
  • subflow:f6a6bc73.5c237 (x5)
  • tab (x1)
  • tls-config (x1)
  • ui_group (x8)
  • ui_tab (x1)
  • ui_template (x1)
  • ui_text (x9)

Tags

  • AWS
  • IOT
  • XBox-360
  • Node-HID
  • MQTT
  • Remote-Control
  • Tele-Operation
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option