led apertura cierre

parent 845bd96d
Showing with 15 additions and 8 deletions
...@@ -21,40 +21,47 @@ var motor = new Gpio(13, { mode: Gpio.OUTPUT }); ...@@ -21,40 +21,47 @@ var motor = new Gpio(13, { mode: Gpio.OUTPUT });
var pulseWidth = 1850; var pulseWidth = 1850;
motor.servoWrite(pulseWidth); motor.servoWrite(pulseWidth);
RED.pwmWrite(255);
GREEN.pwmWrite(0);
BLUE.pwmWrite(0);
// Abrir puerta // Abrir puerta
function abrirPuerta(){ function abrirPuerta(){
GREEN.pwmWrite(255);
var increment = -10; var increment = -10;
var intervalo = setInterval(function () { var intervalo = setInterval(function () {
motor.servoWrite(pulseWidth); motor.servoWrite(pulseWidth);
pulseWidth += increment; pulseWidth += increment;
if (pulseWidth <= 950) { if (pulseWidth <= 950) {
clearInterval(intervalo); clearInterval(intervalo);
} }
}, 100); }, 100);
} }
// Cerrar puerta // Cerrar puerta
function cerrarPuerta(){ function cerrarPuerta(){
RED.pwmWrite(255);
var increment = 10; var increment = 10;
var intervalo = setInterval(function () { var intervalo = setInterval(function () {
motor.servoWrite(pulseWidth); motor.servoWrite(pulseWidth);
pulseWidth += increment; pulseWidth += increment;
if (pulseWidth >= 1850) { if (pulseWidth >= 1850) {
clearInterval(intervalo); clearInterval(intervalo);
} }
}, 100); }, 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