2018.1.32
if __name__ == '__main__': # Program start from here
setup()
try:
while True:
if GPIO.input(BtnPin) == True:
time.sleep(0.01)
if GPIO.input(BtnPin)==True:
GPIO.output(Rpin,1)
GPIO.output(Gpin,0)
elif GPIO.input(BtnPin) == False:
time.sleep(0.01)
if GPIO.input(BtnPin) == False:
while GPIO.input(BtnPin) ==True:
pass
GPIO.output(Rpin,0)
GPIO.output(Gpin,1)
except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed.
GPIO.cleanup()