Skip to content

Instantly share code, notes, and snippets.

@wdelenclos
Created November 3, 2020 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wdelenclos/2299af0b2fbace8994b9fb9e409bc3f5 to your computer and use it in GitHub Desktop.
Save wdelenclos/2299af0b2fbace8994b9fb9e409bc3f5 to your computer and use it in GitHub Desktop.
KY-033 Exemple
# 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