Skip to content

Instantly share code, notes, and snippets.

@abdul-rehman-2050
Created February 14, 2018 15:47
Show Gist options
  • Save abdul-rehman-2050/41ee74a03ba316db4b07bff530bbc283 to your computer and use it in GitHub Desktop.
Save abdul-rehman-2050/41ee74a03ba316db4b07bff530bbc283 to your computer and use it in GitHub Desktop.
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