Created
November 3, 2020 23:40
-
-
Save wdelenclos/2299af0b2fbace8994b9fb9e409bc3f5 to your computer and use it in GitHub Desktop.
KY-033 Exemple
This file contains 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
# Needed modules will be imported and configured | |
import RPi.GPIO as GPIO | |
import time | |
GPIO.setmode(GPIO.BCM) | |
# Declaration of the input pin which is connected with the sensor | |
GPIO_PIN = 18 | |
GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP) | |
# Break between the results will be defined here (in seconds) | |
delayTime = 0.2 | |
print "#--- Hackster project line tracker exemple ---#" | |
# main loop | |
try: | |
while True: | |
if GPIO.input(GPIO_PIN) == False: | |
print "Line detected" | |
# Reset + Delay | |
time.sleep(delayTime) | |
# Scavenging work after the end of the program | |
except KeyboardInterrupt: | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment