Initial revision
This commit is contained in:
commit
9521d790b3
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
28
blink.js
Normal file
28
blink.js
Normal file
@ -0,0 +1,28 @@
|
||||
var rpio = require('rpio')
|
||||
|
||||
var ledOn = false
|
||||
rpio.open(22, rpio.INPUT, rpio.PULL_DOWN)
|
||||
rpio.open(18, rpio.OUTPUT, ledOn ? rpio.HIGH : rpio.LOW)
|
||||
|
||||
function blinkLED() {
|
||||
console.log("blinkLED")
|
||||
ledOn = !ledOn
|
||||
rpio.write(18, ledOn ? rpio.HIGH : rpio.LOW)
|
||||
}
|
||||
|
||||
var blinkInterval = setInterval(blinkLED, 250)
|
||||
|
||||
function endBlinkLED() {
|
||||
rpio.write(18, rpio.LOW)
|
||||
clearInterval(blinkInterval)
|
||||
}
|
||||
|
||||
setTimeout(endBlinkLED, 1000)
|
||||
|
||||
function pushButton() {
|
||||
var buttonPushed = rpio.read(22)
|
||||
console.log("pushButton %d", buttonPushed)
|
||||
rpio.write(18, buttonPushed > 0 ? rpio.HIGH : rpio.LOW)
|
||||
}
|
||||
|
||||
rpio.poll(22, pushButton)
|
25
package-lock.json
generated
Normal file
25
package-lock.json
generated
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"bindings": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz",
|
||||
"integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw=="
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz",
|
||||
"integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY="
|
||||
},
|
||||
"rpio": {
|
||||
"version": "0.9.19",
|
||||
"resolved": "https://registry.npmjs.org/rpio/-/rpio-0.9.19.tgz",
|
||||
"integrity": "sha1-FxtsClVVuerq0xd5Lt2HMWil2Nw=",
|
||||
"requires": {
|
||||
"bindings": "1.3.0",
|
||||
"nan": "2.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
server.js
Normal file
14
server.js
Normal file
@ -0,0 +1,14 @@
|
||||
// Load the http module to create an http server.
|
||||
var http = require('http');
|
||||
|
||||
// Configure our HTTP server to respond with Hello World to all requests.
|
||||
var server = http.createServer(function (request, response) {
|
||||
response.writeHead(200, {"Content-Type": "text/plain"});
|
||||
response.end("Hello World\n");
|
||||
});
|
||||
|
||||
// Listen on port 8080, IP defaults to 0.0.0.0
|
||||
server.listen(8080);
|
||||
|
||||
// Put a friendly message on the terminal
|
||||
console.log("Server running at http://0.0.0.0:8080/");
|
Loading…
Reference in New Issue
Block a user