CARIA.1.0.0
Restruct all repositories Add : - Files UserWebSite - IA openCV Tuto - Alphabot docs for first maquette
This commit is contained in:
38
AlphaBot-CARIA/Pi-python/Infrared_Tracking_Objects.py
Normal file
38
AlphaBot-CARIA/Pi-python/Infrared_Tracking_Objects.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
from AlphaBot import AlphaBot
|
||||
import smbus
|
||||
|
||||
Ab = AlphaBot()
|
||||
|
||||
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)
|
||||
|
||||
Ab.stop()
|
||||
try:
|
||||
while True:
|
||||
|
||||
DR_status = GPIO.input(DR)
|
||||
DL_status = GPIO.input(DL)
|
||||
if((DL_status == 0) and (DR_status == 0)):
|
||||
Ab.forward()
|
||||
print("forward")
|
||||
elif((DL_status == 1) and (DR_status == 0)):
|
||||
Ab.right()
|
||||
print("right")
|
||||
elif((DL_status == 0) and (DR_status == 1)):
|
||||
Ab.left()
|
||||
print("left")
|
||||
else:
|
||||
Ab.stop()
|
||||
print("stop")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup();
|
||||
|
||||
Reference in New Issue
Block a user