Punch Through
Published © MIT

Tweet sentiment to LED using Node-RED

Want to learn how to connect your Bean to the internet? May be you want to tweet a sentiment? Come do this tutorial to learn how!

IntermediateProtip3,509
Tweet sentiment to LED using Node-RED

Things used in this project

Software apps and online services

Node-RED
Node-RED
Punch Through bean loader

Story

Read more

Code

Code snippet #1

Plain text
[{"id":"89e8d4d3.761728","type":"bean led","name":"Mood light LED","bean":"","x":671,"y":528,"z":"273f009f.d8c1","wires":[]},{"id":"e7f572ab.180a9","type":"function","name":"sentiment to LED val","func":"var score = msg.sentiment.score;\n\nif(score > 2){\n    //Good, turn LED green\n    msg.payload = \"Green\";\n}\nelse if(score < -2){\n    //Bad, turn LED red\n    msg.payload = \"Red\";\n}else{\n    //Neutral, turn LED blue\n    msg.payload = \"Blue\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":529,"z":"273f009f.d8c1","wires":[["89e8d4d3.761728"]]},{"id":"cf36b031.30c95","type":"twitter in","twitter":"","tags":"","user":"false","name":"Bean tweets","topic":"tweets","x":121,"y":530,"z":"273f009f.d8c1","wires":[["d0414c8.f2fbeb"]]},{"id":"d0414c8.f2fbeb","type":"sentiment","name":"","x":292,"y":531,"z":"273f009f.d8c1","wires":[["e7f572ab.180a9"]]},{"id":"e8ba696c.174598","type":"inject","name":"","topic":"","payload":"You're great!","payloadType":"string","repeat":"","crontab":"","once":false,"x":134,"y":575,"z":"273f009f.d8c1","wires":[["d0414c8.f2fbeb"]]},{"id":"df800905.207ff8","type":"inject","name":"","topic":"","payload":"You're awful!","payloadType":"string","repeat":"","crontab":"","once":false,"x":137,"y":614,"z":"273f009f.d8c1","wires":[["d0414c8.f2fbeb"]]},{"id":"4906be85.b6f94","type":"inject","name":"","topic":"","payload":"I'm neutral.","payloadType":"string","repeat":"","crontab":"","once":false,"x":136,"y":654,"z":"273f009f.d8c1","wires":[["d0414c8.f2fbeb"]]}]

Credits

Punch Through

Punch Through

16 projects • 41 followers
We’ve been building connected products since 2009. Our diverse team has expertise in every layer from hardware to software to web.

Comments