-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.js
50 lines (35 loc) · 852 Bytes
/
run.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
var GPIO = require('./build/Release/gpio.node')
var in1 = GPIO.pin("PA",6);
var in2 = GPIO.pin("PC",0);
var in3 = GPIO.pin("PC",1);
var in4 = GPIO.pin("PC",2);
var in5 = GPIO.pin("PC",3);
var BTN = GPIO.pin("PG",7);
var LED = GPIO.pin("PG",6);
var JP = GPIO.pin("PG",8)
var AUX = GPIO.pin("PG",11)
GPIO.init();
GPIO.dir(in1, "IN");
GPIO.dir(in2, "IN");
GPIO.dir(in3, "IN");
GPIO.dir(in4, "IN");
GPIO.dir(in5, "IN");
GPIO.dir(LED, "OUT");
setInterval(function(){
console.log("IN1",GPIO.read(in1),"IN2",GPIO.read(in2),"IN3",GPIO.read(in3),"IN4",GPIO.read(in4),"IN5",GPIO.read(in5));
}, 1000);
function high(){
setTimeout(function(){
var ret = GPIO.write(LED, 1);
//console.log(ret);
low();
}, 1000);
}
function low(){
setTimeout(function(){
var ret = GPIO.write(LED, 0);
//console.log(ret);
high();
}, 1000);
}
high();