import RPi.GPIO as GPIO
import time
import webbrowser
red = 2
yellow = 3
green = 4
button = 17
current_led = red
chan_list = [red, yellow, green]
GPIO.setmode(GPIO.BCM)
GPIO.setup(chan_list, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(button)
print(input_state)
if input_state == 0:
newColor = current_led
if current_led is red:
new_color = yellow
if current_led is yellow:
new_color = green
if current_led is green:
new_color = red
print('new_color %i' % new_color)
current_led = newColor
print('current_led %i' % current_led)
GPIO.output(current_led, GPIO.LOW)
time.sleep(0.5)
GPIO.output(current_led, GPIO.HIGH)
time.sleep(0.5)
print newColor == 3 print current_led == 2