-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest_Stepper.js
48 lines (35 loc) · 858 Bytes
/
Test_Stepper.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
const PiMotor = require('./');
const sleep = require('sleep');
const m1 = new PiMotor.Stepper('STEPPER1');
// Rotate Stepper 1 in forward/backward direction
try{
while(true){
// Stepper forward
console.log('Stepper Forward');
m1.forward(0.1, 10);
sleep.sleep(2);
// Stepper reverse
console.log('Stepper Reverse');
m1.backward(0.1, 10);
sleep.sleep(2);
// Stepper stop
console.log('Stepper Stop');
m1.stop();
sleep.sleep(2);
}
} finally{
// Cleanup before exit
if (process.platform === "win32") {
let rl = require("readline").createInterface({
input: process.stdin,
output: process.stdout
});
rl.on("SIGINT", function () {
process.emit("SIGINT");
});
}
process.on('SIGINT', () => {
m1.stop();
process.exit();
});
}