CARIA.2.0
Repo initial CARIA : MAJ Interface Bootle amélioré - Optimisation de la structure - amélioration des fonctionnalités - debug . . .
This commit is contained in:
26
WebControl/tests/infrared_obstacle_module.py
Normal file
26
WebControl/tests/infrared_obstacle_module.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
|
||||
ObstaclePin = 16
|
||||
|
||||
def setup():
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(ObstaclePin, GPIO.IN)
|
||||
|
||||
def loop():
|
||||
while True:
|
||||
if GPIO.input(ObstaclePin) == GPIO.LOW:
|
||||
print("Obstacle détecté")
|
||||
else:
|
||||
print("Aucun obstacle détecté")
|
||||
time.sleep(0.5) # Attendre un peu entre les lectures pour éviter les faux positifs
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
setup()
|
||||
try:
|
||||
loop()
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup()
|
||||
Reference in New Issue
Block a user