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
f65e7b16
authored
Dec 17, 2017
by
Sebastián Collado Montañez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
ultrasonidos test
parent
65f5c994
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
webserver.js
webserver.js
View file @
f65e7b16
...
...
@@ -18,8 +18,9 @@ var RED = new Gpio(4, { mode: Gpio.OUTPUT });
var
GREEN
=
new
Gpio
(
17
,
{
mode
:
Gpio
.
OUTPUT
});
var
BLUE
=
new
Gpio
(
27
,
{
mode
:
Gpio
.
OUTPUT
});
var
motor
=
new
Gpio
(
13
,
{
mode
:
Gpio
.
OUTPUT
});
var
trigger
=
new
Gpio
(
23
,
{
mode
:
Gpio
.
OUTPUT
})
,
var
trigger
=
new
Gpio
(
23
,
{
mode
:
Gpio
.
OUTPUT
})
;
var
echo
=
new
Gpio
(
24
,
{
mode
:
Gpio
.
INPUT
,
alert
:
true
});
var
obstaculo
=
false
;
var
MICROSECDONDS_PER_CM
=
1
e6
/
34321
;
...
...
@@ -43,11 +44,18 @@ trigger.digitalWrite(0);
}
else
{
endTick
=
tick
;
diff
=
(
endTick
>>
0
)
-
(
startTick
>>
0
);
// Unsigned 32 bit arithmetic
console
.
log
(
diff
/
2
/
MICROSECDONDS_PER_CM
);
if
((
diff
/
2
/
MICROSECDONDS_PER_CM
)
<
10.0
){
obstaculo
=
true
;
}
else
{
obstaculo
=
false
;
}
}
});
}());
// Trigger a distance measurement once per second
setInterval
(
function
()
{
trigger
.
trigger
(
10
,
1
);
// Set trigger high for 10 microseconds
...
...
@@ -92,6 +100,11 @@ function cerrarPuerta(){
clearInterval
(
intervalo
);
}
if
(
obstaculo
){
clearInterval
(
intervalo
);
abrirPuerta
();
}
},
100
);
}
...
...
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