Created
April 20, 2018 08:15
-
-
Save Kalimaha/f472e31a4ab1e0d307e229c086c5a4cd to your computer and use it in GitHub Desktop.
obstacle detection sensor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import RPi.GPIO as GPIO | |
| import time | |
| GPIO.setmode(GPIO.BCM) | |
| GPIO_PIN = 24 | |
| GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP) | |
| delayTime = 0.5 | |
| print "Sensor-Test [press ctrl+c to end]" | |
| try: | |
| while True: | |
| if GPIO.input(GPIO_PIN) == True: | |
| print "No obstacle" | |
| else: | |
| print "Obstacle detected" | |
| time.sleep(delayTime) | |
| except KeyboardInterrupt: | |
| GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment