Permalink
Fetching contributors…
Cannot retrieve contributors at this time
84 lines (47 sloc) 1.32 KB

Shift Register - Seven Segment controller

Breadboard for "Shift Register - Seven Segment controller"

docs/breadboard/shift-register-seven-segment.png

Fritzing diagram: docs/breadboard/shift-register-seven-segment.fzz

 

Run this example from the command line with:

node eg/shift-register-seven-segment.js
var five = require("johnny-five");
var board = new five.Board();

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

  // Display numbers 0-9, one at a time in a loop.
  // Shows just the number for a half second, then
  // the number + a decimal point for a half second.
  setInterval(function() {
    register.display(number + (decimal && "."));

    if (decimal) {
      number++;
    }

    if (number > 9) {
      number = 0;
    }

    decimal ^= 1;
  }, 500);
});

 

License

Copyright (c) 2012-2014 Rick Waldron waldron.rick@gmail.com Licensed under the MIT license. Copyright (c) 2015-2018 The Johnny-Five Contributors Licensed under the MIT license.