servo test

parent 9ff5319e
Showing with 6 additions and 4 deletions
...@@ -23,14 +23,14 @@ function abrirPuerta(){ ...@@ -23,14 +23,14 @@ function abrirPuerta(){
var increment = -10; var increment = -10;
var intervaloApertura = setInterval(function () { var intervalo = setInterval(function () {
motor.servoWrite(pulseWidth); motor.servoWrite(pulseWidth);
pulseWidth += increment; pulseWidth += increment;
if (pulseWidth <= 950) { if (pulseWidth <= 950) {
clearInterval(intervaloApertura); clearInterval(intervalo);
} }
}, 100); }, 100);
...@@ -41,21 +41,23 @@ function cerrarPuerta(){ ...@@ -41,21 +41,23 @@ function cerrarPuerta(){
var increment = 10; var increment = 10;
var intervaloApertura = setInterval(function () { var intervalo = setInterval(function () {
motor.servoWrite(pulseWidth); motor.servoWrite(pulseWidth);
pulseWidth += increment; pulseWidth += increment;
if (pulseWidth >= 1850) { if (pulseWidth >= 1850) {
clearInterval(intervaloApertura); clearInterval(intervalo);
} }
}, 100); }, 100);
} }
abrirPuerta(); abrirPuerta();
console.log("Fin 1");
cerrarPuerta(); cerrarPuerta();
console.log("Fin 2");
// Clean LEDs // Clean LEDs
//RED.pwmWrite(dutyCycle); //RED.pwmWrite(dutyCycle);
......
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