Commit 5519bc95 authored by Aadil M. Alli's avatar Aadil M. Alli

Upload New File

parent 29212783
import RPi.GPIO as GPIO
import time
from AlphaBot2 import AlphaBot2
Ab = AlphaBot2()
DR = 16
DL = 19
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(DR,GPIO.IN,GPIO.PUD_UP)
GPIO.setup(DL,GPIO.IN,GPIO.PUD_UP)
try:
while True:
DR_status = GPIO.input(DR)
DL_status = GPIO.input(DL)
print("DR_status:", DR_status)
print("DL_status:", DL_status)
# print(DR_status,DL_status)
if (DL_status == 0):
Ab.left()
#Ab.right()
time.sleep(0.01)
Ab.stop()
# print("object")
elif (DR_status == 0):
Ab.right()
time.sleep(0.01)
Ab.stop()
else:
Ab.forward()
# print("forward")
except KeyboardInterrupt:
GPIO.cleanup();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment