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
23a02e8c
Commit
23a02e8c
authored
Feb 09, 2023
by
Aadil M. Alli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
5519bc95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
Joystick.py
Alphabot2-Lab/Joystick.py
+64
-0
No files found.
Alphabot2-Lab/Joystick.py
0 → 100644
View file @
23a02e8c
import
RPi.GPIO
as
GPIO
import
time
from
AlphaBot2
import
AlphaBot2
Ab
=
AlphaBot2
()
CTR
=
7
A
=
8
B
=
9
C
=
10
D
=
11
BUZ
=
4
def
beep_on
():
GPIO
.
output
(
BUZ
,
GPIO
.
HIGH
)
def
beep_off
():
GPIO
.
output
(
BUZ
,
GPIO
.
LOW
)
GPIO
.
setmode
(
GPIO
.
BCM
)
GPIO
.
setwarnings
(
False
)
GPIO
.
setup
(
CTR
,
GPIO
.
IN
,
GPIO
.
PUD_UP
)
GPIO
.
setup
(
A
,
GPIO
.
IN
,
GPIO
.
PUD_UP
)
GPIO
.
setup
(
B
,
GPIO
.
IN
,
GPIO
.
PUD_UP
)
GPIO
.
setup
(
C
,
GPIO
.
IN
,
GPIO
.
PUD_UP
)
GPIO
.
setup
(
D
,
GPIO
.
IN
,
GPIO
.
PUD_UP
)
GPIO
.
setup
(
BUZ
,
GPIO
.
OUT
)
try
:
while
True
:
if
GPIO
.
input
(
CTR
)
==
0
:
beep_on
();
Ab
.
stop
();
print
(
"center"
)
while
GPIO
.
input
(
CTR
)
==
0
:
time
.
sleep
(
0.01
)
elif
GPIO
.
input
(
A
)
==
0
:
beep_on
();
Ab
.
forward
();
print
(
"up"
)
while
GPIO
.
input
(
A
)
==
0
:
time
.
sleep
(
0.01
)
elif
GPIO
.
input
(
B
)
==
0
:
beep_on
();
Ab
.
right
();
print
(
"right"
)
while
GPIO
.
input
(
B
)
==
0
:
time
.
sleep
(
0.01
)
elif
GPIO
.
input
(
C
)
==
0
:
beep_on
();
Ab
.
left
();
print
(
"left"
)
while
GPIO
.
input
(
C
)
==
0
:
time
.
sleep
(
0.01
)
elif
GPIO
.
input
(
D
)
==
0
:
beep_on
();
Ab
.
backward
();
print
(
"down"
)
while
GPIO
.
input
(
D
)
==
0
:
time
.
sleep
(
0.01
)
else
:
beep_off
();
except
KeyboardInterrupt
:
GPIO
.
cleanup
()
\ No newline at end of file
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