Skip to content
Rick Waldron edited this page Feb 4, 2015 · 17 revisions

The ShiftRegister class constructs an object that represents a shift register.

Parameters

  • options An object of constructor parameters
Name Type Value(s) Description Required
pins Object { data, clock, latch } Sets the values of the data , clock and latch pins yes

Shape

{
  id: A user definable id value. Defaults to a generated uid
  pins : the object containing the pin values for data, clock and latch 
}

Component Initialization

var register = new five.ShiftRegister({
  pins: {
    data: 2,
    clock: 3,
    latch: 4
  }
});

Shift Register

Usage

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

// This works with the 74HC595 that comes with the SparkFun Inventor's kit.
// Your mileage may vary with other chips. For more information on working
// with shift registers, see http://arduino.cc/en/Tutorial/ShiftOut

board.on("ready", function() {
  var register = new five.ShiftRegister({
    pins: {
      data: 2,
      clock: 3,
      latch: 4
    }
  });

  var value = 0;

  function next() {
    value = value > 0x11 ? value >> 1 : 0x88;
    register.send(value);
    setTimeout(next, 200);
  }

  next();
});

API

  • send(value) send a value to the shift register.

Events

ShiftRegister objects are output only and therefore do not emit any events.

Examples

Clone this wiki locally