Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MEND
electrical
Commits
86e75f3f
Commit
86e75f3f
authored
Mar 09, 2021
by
ssshroff
Browse files
Working version
parent
ac6624fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Main_working.ino
0 → 100644
View file @
86e75f3f
const
int
trigPin1
=
9
;
const
int
echoPin1
=
8
;
const
int
trigPin2
=
6
;
const
int
echoPin2
=
7
;
long
duration1
;
long
duration2
;
int
distance1
;
int
distance2
;
void
setup
()
{
// put your setup code here, to run once:
pinMode
(
trigPin1
,
OUTPUT
);
// Sets the trigPin as an Output
pinMode
(
echoPin1
,
INPUT
);
// Sets the echoPin as an Input
pinMode
(
trigPin2
,
OUTPUT
);
// Sets the trigPin as an Output
pinMode
(
echoPin2
,
INPUT
);
// Sets the echoPin as an Input
Serial
.
begin
(
9600
);
// Starts the serial communication
}
void
loop
()
{
// put your main code here, to run repeatedly:
digitalWrite
(
trigPin1
,
LOW
);
delayMicroseconds
(
2
);
digitalWrite
(
trigPin1
,
HIGH
);
delayMicroseconds
(
10
);
digitalWrite
(
trigPin1
,
LOW
);
duration1
=
pulseIn
(
echoPin1
,
HIGH
);
distance1
=
duration1
*
0.034
/
2
;
Serial
.
print
(
"Sensor 1:"
);
Serial
.
println
(
distance1
);
digitalWrite
(
trigPin2
,
LOW
);
delayMicroseconds
(
2
);
digitalWrite
(
trigPin2
,
HIGH
);
delayMicroseconds
(
10
);
digitalWrite
(
trigPin2
,
LOW
);
duration2
=
pulseIn
(
echoPin2
,
HIGH
);
distance2
=
duration2
*
0.034
/
2
;
Serial
.
print
(
"Sensor 2:"
);
Serial
.
println
(
distance2
);
}
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