-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ShiftRegister
Rick Waldron edited this page Feb 4, 2015
·
17 revisions
The ShiftRegister class constructs an object that represents a shift register.
- 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 |
{
id: A user definable id value. Defaults to a generated uid
pins : the object containing the pin values for data, clock and latch
}
var register = new five.ShiftRegister({
pins: {
data: 2,
clock: 3,
latch: 4
}
});
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();
});- send(value) send a value to the shift register.
ShiftRegister objects are output only and therefore do not emit any events.