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
1e7c7e89
Commit
1e7c7e89
authored
Feb 09, 2023
by
Aadil M. Alli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
460d8599
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
134 additions
and
0 deletions
+134
-0
0_Guide_Explained
Alphabot2-Lab/0_Guide_Explained
+134
-0
No files found.
Alphabot2-Lab/0_Guide_Explained
0 → 100644
View file @
1e7c7e89
Explains terms and function uses in Alphabot Class (AlphaBot2.py)
----------------------------------------------------------------
def __init__(self,ain1=20,ain2=21,ena=6,bin1=12,bin2=13,enb=26):
self.AIN1 = ain1
self.AIN2 = ain2
self.BIN1 = bin1
self.BIN2 = bin2
self.ENA = ena
self.ENB = enb
self.PA = 15
self.PB = 15
self.PA = 15
self.PB = 15
Sets default value of speed to 15
Calibrates individual parts of robot
----------------------------------------------------------------
def forward(self):
self.PWMA.ChangeDutyCycle(self.PA)
self.PWMB.ChangeDutyCycle(self.PB)
GPIO.output(self.AIN1,GPIO.LOW)
GPIO.output(self.AIN2,GPIO.HIGH)
GPIO.output(self.BIN1,GPIO.LOW)
GPIO.output(self.BIN2,GPIO.HIGH)
forward()
Robot moves forward at default speed when called
----------------------------------------------------------------
def stop(self):
self.PWMA.ChangeDutyCycle(0)
self.PWMB.ChangeDutyCycle(0)
GPIO.output(self.AIN1,GPIO.LOW)
GPIO.output(self.AIN2,GPIO.LOW)
GPIO.output(self.BIN1,GPIO.LOW)
GPIO.output(self.BIN2,GPIO.LOW)
stop()
Stops robot when called
----------------------------------------------------------------
def backward(self):
self.PWMA.ChangeDutyCycle(self.PA)
self.PWMB.ChangeDutyCycle(self.PB)
GPIO.output(self.AIN1,GPIO.HIGH)
GPIO.output(self.AIN2,GPIO.LOW)
GPIO.output(self.BIN1,GPIO.HIGH)
GPIO.output(self.BIN2,GPIO.LOW)
backward()
Robot moves backward at default speed when called
----------------------------------------------------------------
def left(self):
self.PWMA.ChangeDutyCycle(25)
self.PWMB.ChangeDutyCycle(25)
GPIO.output(self.AIN1,GPIO.HIGH)
GPIO.output(self.AIN2,GPIO.LOW)
GPIO.output(self.BIN1,GPIO.LOW)
GPIO.output(self.BIN2,GPIO.HIGH)
left()
Robot turns left when called
----------------------------------------------------------------
def right(self):
self.PWMA.ChangeDutyCycle(25)
self.PWMB.ChangeDutyCycle(25)
GPIO.output(self.AIN1,GPIO.LOW)
GPIO.output(self.AIN2,GPIO.HIGH)
GPIO.output(self.BIN1,GPIO.HIGH)
GPIO.output(self.BIN2,GPIO.LOW)
right()
Robot turns right when called
----------------------------------------------------------------
def setPWMA(self,value):
self.PA = value
self.PWMA.ChangeDutyCycle(self.PA)
Sets all speeds on A to value (int)
setPWMA(15)
Sets all speeds on A to 15
----------------------------------------------------------------
def setPWMB(self,value):
self.PB = value
self.PWMB.ChangeDutyCycle(self.PB)
Sets all speeds on B to value (int)
setPWMB(15)
Sets all speeds on B to 15
----------------------------------------------------------------
def setMotor(self, left, right):
if((right >= 0) and (right <= 100)):
GPIO.output(self.AIN1,GPIO.HIGH)
GPIO.output(self.AIN2,GPIO.LOW)
self.PWMA.ChangeDutyCycle(right)
elif((right < 0) and (right >= -100)):
GPIO.output(self.AIN1,GPIO.LOW)
GPIO.output(self.AIN2,GPIO.HIGH)
self.PWMA.ChangeDutyCycle(0 - right)
if((left >= 0) and (left <= 100)):
GPIO.output(self.BIN1,GPIO.HIGH)
GPIO.output(self.BIN2,GPIO.LOW)
self.PWMB.ChangeDutyCycle(left)
elif((left < 0) and (left >= -100)):
GPIO.output(self.BIN1,GPIO.LOW)
GPIO.output(self.BIN2,GPIO.HIGH)
self.PWMB.ChangeDutyCycle(0 - left)
Sets given values to left and right motors (int)
setMotor(15, 20)
Sets 15 to left motor and 20 to right motor
----------------------------------------------------------------
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