Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save armintelker/825b0d319d2c9a8da0a2fd602117d7e9 to your computer and use it in GitHub Desktop.
Save armintelker/825b0d319d2c9a8da0a2fd602117d7e9 to your computer and use it in GitHub Desktop.
Python LED Schaltung
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment