Skip to content

Instantly share code, notes, and snippets.

@NeilCFord
Created February 19, 2016 17:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeilCFord/97ca18dceaa1d76001be to your computer and use it in GitHub Desktop.
Save NeilCFord/97ca18dceaa1d76001be to your computer and use it in GitHub Desktop.
A Node-RED flow for a PiZero/Explorer pHat powered bot that moves randomly in response to Twitter
[{"id":"fd281537.bb234","type":"twitter in","z":"422b74cb.e7ca14","twitter":"","tags":"#robotweet","user":"false","name":"Twitter","topic":"tweets","x":55,"y":447,"wires":[["186743dc.d9a4d4","122e8f2d.2c2e91"]]},{"id":"b6577013.c6b1b8","type":"rpi-gpio out","z":"422b74cb.e7ca14","name":"Motor 2 +","pin":"40","set":true,"level":"0","out":"out","x":810,"y":57,"wires":[]},{"id":"651477be.f76588","type":"rpi-gpio out","z":"422b74cb.e7ca14","name":"Motor 2 -","pin":"37","set":true,"level":"0","out":"out","x":809,"y":146,"wires":[]},{"id":"2e8f1150.62cefe","type":"rpi-gpio out","z":"422b74cb.e7ca14","name":"Motor 1 +","pin":"35","set":true,"level":"0","out":"out","x":808,"y":243,"wires":[]},{"id":"a7b1651d.3f1de","type":"rpi-gpio out","z":"422b74cb.e7ca14","name":"Motor 1 -","pin":"38","set":true,"level":"0","out":"out","x":806,"y":334,"wires":[]},{"id":"db739db1.91e7e8","type":"inject","z":"422b74cb.e7ca14","name":"forward","topic":"","payload":"1","payloadType":"string","repeat":"","crontab":"","once":false,"x":256,"y":105,"wires":[["2f3508d2.31d288"]]},{"id":"2f3508d2.31d288","type":"trigger","z":"422b74cb.e7ca14","op1":"1","op2":"0","op1type":"val","op2type":"val","duration":"2","extend":false,"units":"s","name":"forward trigger","x":562,"y":104,"wires":[["b6577013.c6b1b8","2e8f1150.62cefe","f45e28e3.dff118"]]},{"id":"d08bb5c9.fce11","type":"trigger","z":"422b74cb.e7ca14","op1":"1","op2":"0","op1type":"val","op2type":"val","duration":"2","extend":false,"units":"s","name":"backward trigger","x":555,"y":174,"wires":[["651477be.f76588","a7b1651d.3f1de","546df40a.e70ebc"]]},{"id":"786c7801.6fb05","type":"inject","z":"422b74cb.e7ca14","name":"backward","topic":"","payload":"1","payloadType":"string","repeat":"","crontab":"","once":false,"x":248,"y":174,"wires":[["d08bb5c9.fce11"]]},{"id":"15baad61.1b163b","type":"inject","z":"422b74cb.e7ca14","name":"left","topic":"","payload":"1","payloadType":"string","repeat":"","crontab":"","once":false,"x":254,"y":237,"wires":[["c20d052e.7a62b"]]},{"id":"16c8643a.bb3ec4","type":"inject","z":"422b74cb.e7ca14","name":"right","topic":"","payload":"1","payloadType":"string","repeat":"","crontab":"","once":false,"x":253,"y":299,"wires":[["3fc320c5.e9016"]]},{"id":"c20d052e.7a62b","type":"trigger","z":"422b74cb.e7ca14","op1":"1","op2":"0","op1type":"val","op2type":"val","duration":"250","extend":false,"units":"ms","name":"left trigger","x":575,"y":236,"wires":[["b6577013.c6b1b8","a7b1651d.3f1de","353e7a0c.90d82e"]]},{"id":"3fc320c5.e9016","type":"trigger","z":"422b74cb.e7ca14","op1":"1","op2":"0","op1type":"val","op2type":"val","duration":"250","extend":false,"units":"ms","name":"right trigger","x":572,"y":298,"wires":[["2e8f1150.62cefe","651477be.f76588","d44d2214.09ead"]]},{"id":"3a66052f.ca24f2","type":"random","z":"422b74cb.e7ca14","name":"random movement","low":"1","high":"4","inte":"true","x":292,"y":447,"wires":[["b8a74390.76ed2","27997e89.6ff832"]]},{"id":"b8a74390.76ed2","type":"switch","z":"422b74cb.e7ca14","name":"choose movement","property":"payload","rules":[{"t":"eq","v":"1"},{"t":"eq","v":"2"},{"t":"eq","v":"3"},{"t":"eq","v":"4"}],"checkall":"true","outputs":4,"x":538,"y":447,"wires":[["2f3508d2.31d288"],["d08bb5c9.fce11"],["c20d052e.7a62b"],["3fc320c5.e9016"]]},{"id":"186743dc.d9a4d4","type":"debug","z":"422b74cb.e7ca14","name":"Twitter debug","active":true,"console":"false","complete":"payload","x":275,"y":504,"wires":[]},{"id":"b005aa31.e7912","type":"comment","z":"422b74cb.e7ca14","name":"Twitter controlled random robot","info":"Using a Pi Zero and an Explorer pHAT mounted \non a Zumo chassis, any tweet matching the search \ncriteria will cause the robot to move in a \nrandom direction.","x":156,"y":36,"wires":[]},{"id":"f45e28e3.dff118","type":"debug","z":"422b74cb.e7ca14","name":"forward debug","active":true,"console":"false","complete":"payload","x":824,"y":108,"wires":[]},{"id":"546df40a.e70ebc","type":"debug","z":"422b74cb.e7ca14","name":"backward debug","active":true,"console":"false","complete":"payload","x":833,"y":200,"wires":[]},{"id":"353e7a0c.90d82e","type":"debug","z":"422b74cb.e7ca14","name":"left debug","active":true,"console":"false","complete":"payload","x":808,"y":293,"wires":[]},{"id":"d44d2214.09ead","type":"debug","z":"422b74cb.e7ca14","name":"right debug","active":true,"console":"false","complete":"payload","x":813,"y":383,"wires":[]},{"id":"27997e89.6ff832","type":"debug","z":"422b74cb.e7ca14","name":"random debug","active":true,"console":"false","complete":"payload","x":528,"y":505,"wires":[]},{"id":"122e8f2d.2c2e91","type":"delay","z":"422b74cb.e7ca14","name":"Limit: 1 msg / sec","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":168,"y":391,"wires":[["3a66052f.ca24f2"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment