monteslu / node-red-contrib-gpio

A set of node-red nodes for connecting to johnny-five IO Plugins
MIT License
41 stars 31 forks source link

Why is there an input terminal on the Johnny5 node? #19

Closed nkolban closed 8 years ago

nkolban commented 8 years ago

From what I understand, the Johnny5 node is run when a flow is started. If that is the case, why then does it have a wireable input node? Wouldn't it make sense to have no input terminal on the node at all? Is there some circumstance where wiring input into "Johnny5" would be a useful task?

monteslu commented 8 years ago

@nkolban it actually serves a purpose, just not well documented :)

If you connect something to the input, you can receive those messages in your johnny-five script such as:


node.on('input', function(msg){
  //do something cool with input messages...
});

similarly, you can also send out messages with the node object:


node.send({topic: 'johnny 5 stuff', payload: 'some sensor data'});

The pagenodes johnny-five nodes work the same way with inputs and outpus. In fact, we used the input connection with gamepads during nodebots day a couple weeks ago:

https://twitter.com/samrocksc/status/757005553012871168

nkolban commented 8 years ago

Awesome ... thank you. And thanks for the fantastic project. Super cool. Am making good use of it in a forthcoming book ... https://leanpub.com/chip