Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
Aadil Work
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aadil M. Alli
Aadil Work
Commits
56eb9430
Commit
56eb9430
authored
Feb 09, 2023
by
Aadil M. Alli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete Ultrasonic_Obstacle_Avoidance.py
parent
87a5031f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
40 deletions
+0
-40
Ultrasonic_Obstacle_Avoidance.py
Ultrasonic_Obstacle_Avoidance.py
+0
-40
No files found.
Ultrasonic_Obstacle_Avoidance.py
deleted
100644 → 0
View file @
87a5031f
import
RPi.GPIO
as
GPIO
import
time
from
AlphaBot2
import
AlphaBot2
TRIG
=
22
ECHO
=
27
Ab
=
AlphaBot2
()
GPIO
.
setmode
(
GPIO
.
BCM
)
GPIO
.
setwarnings
(
False
)
GPIO
.
setup
(
TRIG
,
GPIO
.
OUT
,
initial
=
GPIO
.
LOW
)
GPIO
.
setup
(
ECHO
,
GPIO
.
IN
)
def
Distance
():
GPIO
.
output
(
TRIG
,
GPIO
.
HIGH
)
time
.
sleep
(
0.000015
)
GPIO
.
output
(
TRIG
,
GPIO
.
LOW
)
while
not
GPIO
.
input
(
ECHO
):
pass
t1
=
time
.
time
()
while
GPIO
.
input
(
ECHO
):
pass
t2
=
time
.
time
()
return
(
t2
-
t1
)
*
34000
/
2
print
(
"Ultrasonic_Obstacle_Avoidance"
)
try
:
while
True
:
Dist
=
Distance
()
print
(
"Distance =
%0.2
f cm"
%
Dist
)
if
Dist
<=
20
:
Ab
.
right
()
# Ab.left()
else
:
Ab
.
forward
()
time
.
sleep
(
0.02
)
except
KeyboardInterrupt
:
GPIO
.
cleanup
();
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