Created
February 14, 2018 15:47
-
-
Save abdul-rehman-2050/41ee74a03ba316db4b07bff530bbc283 to your computer and use it in GitHub Desktop.
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 ALIASES [BCM MODE] ==================== | |
LED1 = 19 #BCM MODE | |
LED2 = 26 | |
#--- INPUT PUSH BUTTONS --------------------------------- | |
SW1 = 6 | |
SW2 = 13 | |
#======================================================= | |
GPIO.setmode(GPIO.BCM) | |
#------------------------- | |
GPIO.setup(LED1,GPIO.OUT) | |
GPIO.setup(LED2,GPIO.OUT) | |
GPIO.setup(SW1,GPIO.IN) | |
GPIO.setup(SW2,GPIO.IN) | |
#------------------------ | |
GPIO.output(LED1,GPIO.HIGH) | |
GPIO.output(LED2,GPIO.LOW) | |
try: | |
for i in range(1,800): | |
if not GPIO.input(SW1): | |
GPIO.output(LED1,True) | |
else: | |
GPIO.output(LED1,False) | |
if not GPIO.input(SW2): | |
for j in range(1,5): | |
GPIO.output(LED2,False) | |
time.sleep(0.5) | |
GPIO.output(LED2,True) | |
time.sleep(0.5) | |
else: | |
GPIO.output(LED2,True) | |
time.sleep(0.02) | |
finally: | |
GPIO.cleanup() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment