Browse By

Arduino Relay Control with Johnny-Five

Johnny-Five is getting popular and day by day more and more people are using it for programming devices like Arduino, intel Galileo, beaglebone etc. It needs NodeJs and this means that the code you write for your Arduino is in Javascript language. How convenient?  As an example see below how you can control a relay.

Connection should be made like this:

relay-arduino

 

And the code looks like this:

var five = require("johnny-five"),
  board = new five.Board();

board.on("ready", function() {
  var relay = new five.Relay(10);

  // From the REPL, toggle the lamp on and off by calling:
  //
  //   relay.toggle()
  //
  this.repl.inject({
    relay: relay
  });
});

Detailed information can be found here and here.

Leave a Reply

Your email address will not be published. Required fields are marked *