Created
December 26, 2020 09:44
-
-
Save wdelenclos/e8a95fbf3e15a06f46eabf3f395ab698 to your computer and use it in GitHub Desktop.
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 = 4 | |
GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP) | |
# Break between the results will be defined here (in seconds) | |
delayTime = 2.5 | |
# main loop | |
try: | |
while True: | |
if GPIO.input(GPIO_PIN) == False: | |
print("Detected") | |
print('\a') | |
# 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