37 lines
647 B
Python
37 lines
647 B
Python
import RPi.GPIO as GPIO
|
|
from time import sleep
|
|
import argparse
|
|
|
|
CHANNEL = 19
|
|
GPIO.setmode(GPIO.BOARD)
|
|
|
|
|
|
def debug():
|
|
standby_for = 30
|
|
while standby_for:
|
|
if GPIO.input(CHANNEL):
|
|
print('Input was HIGH')
|
|
else:
|
|
print('Input was LOW')
|
|
sleep(1)
|
|
standby_for -= 1
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--debug', action='store_true',
|
|
help='Enables the DEBG opcode')
|
|
args = parser.parse_args()
|
|
|
|
GPIO.setup(CHANNEL, GPIO.IN)
|
|
|
|
if args.debug:
|
|
debug()
|
|
GPIO.cleanup()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|
|
|
|
|
|
|