-
Notifications
You must be signed in to change notification settings - Fork 1
/
matrix-loop.js
56 lines (44 loc) · 1015 Bytes
/
matrix-loop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// https://github.com/rwaldron/johnny-five/blob/master/docs/led-matrix.md
// chaining tutorial: https://github.com/rwaldron/johnny-five/blob/master/docs/led-matrix-tutorial.md
// VCC -> +5V
// GND -> GND
const five = require('johnny-five');
const pattern = [
'10000001',
'01000010',
'00100100',
'00011000',
'00011000',
'00100100',
'01000010',
'10000001'
];
new five.Board().on("ready", function() {
const matrix = new five.Led.Matrix({
pins: {
data: 2, // DIN
clock: 3, // CLK
cs: 4 // CS
}
});
matrix.on();
matrix.draw(pattern);
setInterval(function() {
const line = pattern.shift();
pattern.push(line);
matrix.draw(pattern);
}, 30);
// let msg = "johnny-five".split("");
// // Display each letter for 1 second
// function next() {
// var c;
// if (c = msg.shift()) {
// matrix.draw(c);
// setTimeout(next, 1000);
// }
// }
// next();
this.repl.inject({
matrix
});
});