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
df3d2547
authored
Dec 14, 2017
by
Sebastián Collado Montañez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
servo test
parent
177d00fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
webserver.js
webserver.js
View file @
df3d2547
...
@@ -12,17 +12,23 @@ var RED = new Gpio(4, {mode: Gpio.OUTPUT});
...
@@ -12,17 +12,23 @@ var RED = new Gpio(4, {mode: Gpio.OUTPUT});
var
GREEN
=
new
Gpio
(
17
,
{
mode
:
Gpio
.
OUTPUT
});
var
GREEN
=
new
Gpio
(
17
,
{
mode
:
Gpio
.
OUTPUT
});
var
BLUE
=
new
Gpio
(
27
,
{
mode
:
Gpio
.
OUTPUT
});
var
BLUE
=
new
Gpio
(
27
,
{
mode
:
Gpio
.
OUTPUT
});
var
dutyCycle
=
0
;
var
motor
=
new
Gpio
(
10
,
{
mode
:
Gpio
.
OUTPUT
}),
pulseWidth
=
1000
,
increment
=
100
;
setInterval
(
function
()
{
setInterval
(
function
()
{
RED
.
pwmWrite
(
dutyCycle
);
motor
.
servoWrite
(
pulseWidth
);
dutyCycle
+=
5
;
pulseWidth
+=
increment
;
if
(
dutyCycle
>
255
)
{
if
(
pulseWidth
>=
2000
)
{
dutyCycle
=
0
;
increment
=
-
100
;
}
else
if
(
pulseWidth
<=
1000
)
{
increment
=
100
;
}
}
},
2
0
);
},
100
0
);
// Clean LEDs
motor
.
servoWrite
(
1000
);
RED
.
pwmWrite
(
dutyCycle
);
RED
.
pwmWrite
(
dutyCycle
);
GREEN
.
pwmWrite
(
dutyCycle
);
GREEN
.
pwmWrite
(
dutyCycle
);
BLUE
.
pwmWrite
(
dutyCycle
);
BLUE
.
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