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
e68841d9
authored
Dec 14, 2017
by
Sebastián Collado Montañez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
rgb led
parent
65b68e42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
webserver.js
webserver.js
View file @
e68841d9
...
...
@@ -8,29 +8,48 @@ var isPi = require('detect-rpi');
GPIO
*/
var
Gpio
;
var
LED
;
var
blinkInterval
;
var
RED
;
var
RED
;
var
GREEN
;
var
BLUE
;
if
(
isPi
()){
// Init GPIO
Gpio
=
require
(
'onoff'
).
Gpio
;
LED
=
new
Gpio
(
4
,
'out'
);
blinkInterval
=
setInterval
(
blinkLED
,
250
);
function
blinkLED
()
{
if
(
LED
.
readSync
()
===
0
)
{
LED
.
writeSync
(
1
);
}
else
{
LED
.
writeSync
(
0
);
// Set port
RED
=
new
Gpio
(
4
,
'out'
);
blinkInterval
=
setInterval
(
blinkRED
,
250
);
function
blinkRED
()
{
if
(
RED
.
readSync
()
===
1
){
RED
.
writeSync
(
0
);
GREEN
.
writeSync
(
1
);
}
else
if
(
GREEN
.
readSync
()
===
1
){
GREEN
.
writeSync
(
0
);
BLUE
.
writeSync
(
1
);
}
else
if
(
BLUE
.
readSync
()
===
1
){
BLUE
.
writeSync
(
0
);
RED
.
writeSync
(
1
);
}
else
{
RED
.
writeSync
(
0
);
GREEN
.
writeSync
(
0
);
BLUE
.
writeSync
(
0
);
RED
.
writeSync
(
1
);
}
}
function
endBlink
()
{
clearInterval
(
blinkInterval
);
L
ED
.
writeSync
(
0
);
L
ED
.
unexport
();
R
ED
.
writeSync
(
0
);
R
ED
.
unexport
();
}
setTimeout
(
endBlink
,
5000
);
setTimeout
(
endBlink
,
1
5000
);
}
...
...
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