0
API johnny-five/arduino
を使用してJavaScriptでどのようにループしますか?このループは、on/off
を私の手に遅らせることです。例:遅延がJohnny-fiveで導かれました
実際のコードは次のとおりです。私は最後にhttp and others
とlisten
というヘッダーを削除します。
arduino.on('ready', function(){
console.log("Arduino Pronto");
led0 = new five.Led(13);
led1 = new five.Led(12);
led2 = new five.Led(11);
this.digitalRead(10, function(value) {
console.log(value);
});
});
サーバー機能:上
arduinoのか、ボード
function servidor(req, res){
var url = req.url;
if(url == '/'){
res.writeHead(200);
res.end(fs.readFileSync('view/index.html'));
}else if(url == '/led0'){
res.writeHead(302, {'Location': '/'});
res.end();
led0.toggle();
}else if(url == '/led1'){
res.writeHead(302, {'Location': '/'});
res.end();
led1.toggle();
}else if(url == '/led2'){
res.writeHead(302, {'Location': '/'});
res.end();
led2.toggle();
}else{
res.writeHead(200);
res.end("<h1>Erro 404</h1>");
}
};
その可能?
センセーショナル、ありがとうございます! –