⚲
Project
General
Profile
Sign in
Register
Home
Projects
Search
:
Club Robotique
All Projects
Club Robotique
Overview
Activity
Issues
Gantt
Calendar
News
Documents
Wiki
Files
Repository
Download (510 Bytes)
Files
» capteur_ultrason.ino
Jérémie Boulic
, 04/02/2016 11:49 PM
int
trigPin
=
13
;
int
echoPin
=
12
;
long
duration
;
float
d
;
void
setup
()
{
Serial
.
begin
(
9600
);
pinMode
(
trigPin
,
OUTPUT
);
pinMode
(
echoPin
,
INPUT
);
}
void
loop
()
{
d
=
distance
();
Serial
.
print
(
d
);
Serial
.
println
(
" cm"
);
delay
(
100
);
}
float
distance
()
{
digitalWrite
(
trigPin
,
LOW
);
// Added this line
delayMicroseconds
(
2
);
digitalWrite
(
trigPin
,
HIGH
);
delayMicroseconds
(
10
);
// Added this line
digitalWrite
(
trigPin
,
LOW
);
duration
=
pulseIn
(
echoPin
,
HIGH
);
return
(
duration
/
2
)
/
29.1
;
}
« Previous
1
…
3
4
5
6
7
8
Next »
(5-5/8)
Loading...