I am programming arduino boards in javascript. I am trying to connect multiple arduino boards using the johnny-five library. I followed the johnny-five documentation and I can strobe the led 13 on both boards at once.
However my issue is I want to control leds one at a time. How can I specifically initialise LEDs on each board?
There are many examples in the docs for the
Boards
(note the plural) class. I've copied the following directly:The
Boards
class constructs a collection object containing multiple board objects. If no arguments are passed,Board
objects will be created for every board detected in the order that the system enumerates them.See also: Board
Parameters
Initializing Multiple Boards
The easiest way to initialize multiple board objects is to call the
Boards
constructor function withnew
. Don't worry about knowing your device's path or COM port, Johnny-Five will figure out which USBs are in use by compatible boards automatically.Or
Or
Board Ready
Once the board objects have been initialized, they must connect to the physical boards with a set of handshake steps, once this has completed, the boards are ready to communicate with the program. This process is asynchronous, and signified to the program via a "ready" event.
Override this by providing explicit port paths:
Usage
A basic, but complete example usage of the
Boards
constructor:Override this by providing explicit port paths:
NOTE When using multiple boards, all device classes must be initialized with an explicit reference to the board object that they will be associated to. This is illustrated in the previous code example.
API
each(callback(board, index)) Call a function once for each board object.
...
One thing not currently mentioned, which I will update to do so, is that
this
inside of theready
handler is an array-like object containing references to each initialized board, in the order that they were created: