Skip to content

Commit

Permalink
Examples: regenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Sep 17, 2019
1 parent 99ce13b commit 87cbae2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
16 changes: 9 additions & 7 deletions docs/shift-register-daisy-chain-anode.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ board.on("ready", () => {
/**
* Pressing this button will trigger the die roll.
*/
var button = new Button(8);
const button = new Button(8);

/**
* Sends a random number to the shift register.
Expand All @@ -68,12 +68,14 @@ board.on("ready", () => {
* we'll iterate over this array and display a random number after the
* delay. This simulates a die bouncing on a table.
*/
var delays = new Array(10).fill(16)
.concat(new Array(8).fill(32))
.concat(new Array(6).fill(64))
.concat(new Array(4).fill(128))
.concat(new Array(2).fill(256))
.concat(512);
const delays = [
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
32, 32, 32, 32, 32, 32, 32, 32,
64, 64, 64, 64, 64, 64,
128, 128, 128, 128,
256, 256,
512,
];

register.reset();
register.clear();
Expand Down
14 changes: 8 additions & 6 deletions docs/shift-register-daisy-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ board.on("ready", () => {
* we'll iterate over this array and display a random number after the
* delay. This simulates a die bouncing on a table.
*/
const delays = new Array(10).fill(16)
.concat(new Array(8).fill(32))
.concat(new Array(6).fill(64))
.concat(new Array(4).fill(128))
.concat(new Array(2).fill(256))
.concat(512);
const delays = [
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
32, 32, 32, 32, 32, 32, 32, 32,
64, 64, 64, 64, 64, 64,
128, 128, 128, 128,
256, 256,
512,
];

register.reset();
register.clear();
Expand Down
2 changes: 1 addition & 1 deletion docs/shift-register-seven-segment-anode.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ board.on("ready", () => {
number++;
}

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

Expand Down
2 changes: 1 addition & 1 deletion docs/shift-register-seven-segment.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ board.on("ready", () => {
number++;
}

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

Expand Down
14 changes: 9 additions & 5 deletions docs/shift-register.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ board.on("ready", () => {
}
});

let value = 0;
let value = 0b00000000;
let upper = 0b10001000;
let lower = 0b00010001;

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

next();
});

```
Expand Down

0 comments on commit 87cbae2

Please sign in to comment.