forked from rezaprimasatya/Iot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
led.js
176 lines (132 loc) · 3.38 KB
/
led.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//##########################blink
// var five = require("johnny-five");
// var board = new five.Board();
// board.on("ready", function() {
// var led = new five.Led(13);
// this.repl.inject({
// led: led
// });
// led.blink();
// });
//####################blink timer
// var five = require("johnny-five");
// var board = new five.Board();
// board.on("ready", function() {
// var led = new five.Led(13);
// led.blink(500);
// });
//##################blink pulse
// var five = require("johnny-five");
// var board = new five.Board();
// board.on("ready", function() {
// var led = new five.Led(11);
// led.pulse();
// this.wait(10000, function() {
// led.stop().off();
// });
// });
//#################pulse animation
// var five = require("johnny-five");
// var board = new five.Board();
// board.on("ready", function() {
// var led = new five.Led(11);
// led.pulse({
// easing: "linear",
// duration: 3000,
// cuePoints: [0, 0.2, 0.4, 0.6, 0.8, 1],
// keyFrames: [0, 10, 0, 50, 0, 255],
// onstop: function() {
// console.log("Animation stopped");
// }
// });
// this.wait(12000, function() {
// led.stop().off();
// });
// });
//##################led fedin
// var five = require("johnny-five");
// var board = new five.Board();
// board.on("ready", function() {
// var led = new five.Led(11);
// led.fadeIn();
// this.wait(5000, function() {
// led.fadeOut();
// });
// });
//##################led demo sequence
// var five = require("johnny-five");
// var board = new five.Board();
// var led;
// var loop = true;
// var demoSequence = [{
// method: "pulse",
// args: [1000],
// duration: 5000
// }, {
// method: "strobe",
// args: [500],
// duration: 3000
// }, {
// method: "fadeIn",
// args: [
// 2000,
// function() {
// console.log("fadeIn complete!");
// }
// ],
// duration: 2500
// }, {
// method: "fadeOut",
// args: [
// 5000,
// function() {
// console.log("fadeOut complete!");
// }
// ],
// duration: 5500
// }, {
// method: "brightness",
// args: [10],
// duration: 3000
// }, {
// method: "off"
// }];
// // Execute a method in the demo sequence
// function execute(step) {
// // Grab everything we need for this step
// var method = demoSequence[step].method;
// var args = demoSequence[step].args;
// var duration = demoSequence[step].duration || 3000;
// // Just print out what we're executing
// console.log("led." + method + "(" + (args ? args.join() : "") + ")");
// // Make the actual call to the LED
// five.Led.prototype[method].apply(led, args);
// // Increment the step
// step++;
// // If we're at the end, start over (loop==true) or exit
// if (step === demoSequence.length) {
// if (loop) {
// step = 0;
// } else {
// // We're done!
// process.exit(0);
// }
// }
// // Recursively call the next step after specified duration
// board.wait(duration, function() {
// execute(step);
// });
// }
// board.on("ready", function() {
// // Defaults to pin 11 (must be PWM)
// led = new five.Led(process.argv[2] || 11);
// // Kick off the first step
// execute(0);
// });
//##################led array
var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
var array = new five.Leds([3, 5, 6]);
array.pulse();
});