Skip to content

Instantly share code, notes, and snippets.

@jhottell
Last active June 6, 2017 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhottell/9c34d2e8d512bc55bc1a0b64d3de7c88 to your computer and use it in GitHub Desktop.
Save jhottell/9c34d2e8d512bc55bc1a0b64d3de7c88 to your computer and use it in GitHub Desktop.
Tweet to turn on LED in Arduino via MQTT
[{"id":"a36eecac.af905","type":"twitter in","z":"3d42f9b2.cb8456","twitter":"","tags":"electronhacks,Electronhacks","user":"false","name":"Direct","topic":"tweets","inputs":0,"x":186.7840347290039,"y":102.80112361907959,"wires":[["bacc6879.8f34b8","1912a8f2.5c4c67"]]},{"id":"bacc6879.8f34b8","type":"debug","z":"3d42f9b2.cb8456","name":"","active":true,"console":"false","complete":"false","x":699.7812271118164,"y":108.87783718109131,"wires":[]},{"id":"1912a8f2.5c4c67","type":"function","z":"3d42f9b2.cb8456","name":"Check for Keywords","func":"message = msg.payload\nif (message.toLocaleLowerCase().includes(\"red\")) \n{\n return {topic:'Arduino',payload:'Red'}; \n}\nif (message.toLocaleLowerCase().includes(\"green\")) \n{\n return {topic:'Arduino',payload:'Green'}; \n}\nif (message.toLocaleLowerCase().includes(\"blue\")) \n{\n return {topic:'Arduino',payload:'Blue'}; \n}\nif (message.toLocaleLowerCase().includes(\"white\")) \n{\n return {topic:'Arduino',payload:'White'}; \n}\nif (message.toLocaleLowerCase().includes(\"yellow\")) \n{\n return {topic:'Arduino',payload:'Yellow'}; \n}\nif (message.toLocaleLowerCase().includes(\"cyan\")) \n{\n return {topic:'Arduino',payload:'Cyan'}; \n}\nif (message.toLocaleLowerCase().includes(\"magenta\")) \n{\n return {topic:'Arduino',payload:'Magenta'}; \n}\n","outputs":1,"noerr":0,"x":471.78688049316406,"y":183.73862552642822,"wires":[["bacc6879.8f34b8","4d1f9ea2.cdd55"]]},{"id":"4d1f9ea2.cdd55","type":"mqtt out","z":"3d42f9b2.cb8456","name":"","topic":"","qos":"0","retain":"false","broker":"c3f1643d.d91608","x":758.7840194702148,"y":189.1221466064453,"wires":[]},{"id":"79211b62.a0c484","type":"twitter out","z":"3d42f9b2.cb8456","twitter":"","name":"Tweet","x":733.7840538024902,"y":280.14198303222656,"wires":[]},{"id":"50d22dce.038c54","type":"mqtt in","z":"3d42f9b2.cb8456","name":"","topic":"Arduino/Out","qos":"0","broker":"c3f1643d.d91608","x":246.78125,"y":277.9175796508789,"wires":[["79211b62.a0c484"]]},{"id":"c3f1643d.d91608","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"NodeRedPing","usetls":false,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment