forked from jadonk/bonescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.js
More file actions
33 lines (29 loc) · 975 Bytes
/
Copy pathloops.js
File metadata and controls
33 lines (29 loc) · 975 Bytes
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
require('bonescript');
ledPin = bone.USR3;
outputPin = bone.P8_3;
setup = function() {
console.log("Running setup");
pinMode(ledPin, OUTPUT);
pinMode(outputPin, OUTPUT);
digitalWrite(ledPin, LOW);
digitalWrite(outputPin, LOW);
console.log("getLoops() = " + JSON.stringify(getLoops()));
// Start toggling after 5 seconds
setTimeout(function() {
console.log("Flashing LED for 5 seconds");
loopid = addLoop(function() {
digitalWrite(ledPin, HIGH);
digitalWrite(outputPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
digitalWrite(outputPin, LOW);
}, 150);
console.log("loopid = " + loopid);
console.log("getLoops() = " + JSON.stringify(getLoops()));
// Stop toggling after 5 seconds
setTimeout(function() {
removeLoop(loopid)
console.log("Halting flashing of LED");
}, 5000);
}, 5000);
};