led apertura cierre

parent 845bd96d
Showing with 15 additions and 8 deletions
......@@ -21,40 +21,47 @@ var motor = new Gpio(13, { mode: Gpio.OUTPUT });
var pulseWidth = 1850;
motor.servoWrite(pulseWidth);
RED.pwmWrite(255);
GREEN.pwmWrite(0);
BLUE.pwmWrite(0);
// Abrir puerta
function abrirPuerta(){
GREEN.pwmWrite(255);
var increment = -10;
var intervalo = setInterval(function () {
motor.servoWrite(pulseWidth);
pulseWidth += increment;
if (pulseWidth <= 950) {
clearInterval(intervalo);
}
}, 100);
}
// Cerrar puerta
function cerrarPuerta(){
RED.pwmWrite(255);
var increment = 10;
var intervalo = setInterval(function () {
motor.servoWrite(pulseWidth);
pulseWidth += increment;
if (pulseWidth >= 1850) {
clearInterval(intervalo);
}
}, 100);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment