title: Raspberry Pi - stopping while loop with push switch
body: <p>Just to save time, the code starts a loop for two leds blinking back and forth after pushing a switch on the right. What I've been trying to do --without success obviously-- is stop the while loop by pressing a second switch on the left to turn both leds off and the code completely stop. Any help or hints would be greatly appreciated it.</p>
  
  <pre><code>import RPi.GPIO as GPIO
  import time 
  
  GPIO.setmode(GPIO.BOARD)
  
  leftLED = 22
  rightLED = 18
  leftSWITCH = 24
  rightSWITCH = 16
  
  GPIO.setup(leftLED, GPIO.OUT)
  GPIO.setup(rightLED, GPIO.OUT)
  GPIO.setup(leftSWITCH, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  GPIO.setup(rightSWITCH, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  GPIO.output(leftLED, False)
  GPIO.output(rightLED, False)
  try:
      print("press the left button to start. Press the right button to stop.")
  while True:
      input_state = GPIO.input(leftSWITCH)
      if input_state == False:
  
          while True:
              input_state1 = GPIO.input(rightSWITCH)
  
              GPIO.output(rightLED, GPIO.LOW)
              time.sleep(.5)
  
              GPIO.output(rightLED, GPIO.HIGH)
              time.sleep(.1)
  
              GPIO.output(leftLED, GPIO.LOW)
              time.sleep(.5)
  
              GPIO.output(leftLED, GPIO.HIGH)
              time.sleep(.1)
  
            if input_state1 == False:
              break
  
  
  
  
  
   finally:
       GPIO.cleanup()
  </code></pre>