Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Sebastián Collado Montañez
/
proyecto-micro
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9ff5319e
authored
Dec 15, 2017
by
Sebastián Collado Montañez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
servo test
parent
f232f218
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
webserver.js
webserver.js
View file @
9ff5319e
...
...
@@ -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 () {
// Abrir puerta
function
abrirPuerta
(){
var
increment
=
-
10
;
var
intervaloApertura
=
setInterval
(
function
()
{
motor
.
servoWrite
(
pulseWidth
);
pulseWidth
+=
increment
;
if (pulseWidth >= 1850) {
increment = -10;
} else if (pulseWidth <= 950) {
increment = 10;
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);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment