servo test

parent f232f218
Showing with 21 additions and 15 deletions
......@@ -17,32 +17,37 @@ var motor = new Gpio(13, { mode: Gpio.OUTPUT });
// Puerta abierta: 950
// Rango apertura: 900
var pulseWidth = 1850;
var increment = -10;
// Apertura y cierre continuo
/*setInterval(function () {
motor.servoWrite(pulseWidth);
// Abrir puerta
function abrirPuerta(){
pulseWidth += increment;
var increment = -10;
if (pulseWidth >= 1850) {
increment = -10;
} else if (pulseWidth <= 950) {
increment = 10;
}
var intervaloApertura = setInterval(function () {
motor.servoWrite(pulseWidth);
pulseWidth += increment;
if (pulseWidth <= 950) {
clearInterval(intervaloApertura);
}
}, 100);
}
}, 100);*/
// Cerrar puerta
function cerrarPuerta(){
var increment = 10;
// Apertura
function abrirPuerta(){
var intervaloApertura = setInterval(function () {
motor.servoWrite(pulseWidth);
pulseWidth += increment;
if (pulseWidth >= 1850) {
increment = -10;
} else if (pulseWidth <= 950) {
clearInterval(intervaloApertura);
}
......@@ -50,6 +55,7 @@ function abrirPuerta(){
}
abrirPuerta();
cerrarPuerta();
// Clean LEDs
//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