Created
June 11, 2017 12:44
-
-
Save ruanyf/15c79ffde8e34b197f6ab0d75d89846a to your computer and use it in GitHub Desktop.
A server with LED on Raspberry Pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var server = require('server'); | |
var { get } = server.router; | |
var rpio = require('rpio'); | |
rpio.open(11, rpio.OUTPUT); | |
function blink() { | |
rpio.write(11, rpio.HIGH); | |
setTimeout(function ledoff() { | |
rpio.write(11, rpio.LOW); | |
}, 50); | |
} | |
server({ port: 8080 }, [ | |
get('/' , ctx => { | |
console.log('a request is coming...'); | |
blink(); | |
}), | |
]); | |
console.log('server starts on 8080 port'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment