Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- GPIO.setwarnings(False)
- GPIO.setmode(GPIO.BCM)
- PIN_LED_RED = 14
- PIN_LED_GRE = 23
- PIN_BUTTON = 15
- GPIO.setup(PIN_LED_RED, GPIO.OUT)
- GPIO.setup(PIN_LED_GRE, GPIO.OUT)
- GPIO.setup(PIN_BUTTON, GPIO.IN)
- GPIO.output(PIN_LED_RED, 1)
- btn_clicked = False
- i = 5
- while True:
- btn_clicked = GPIO.input(PIN_BUTTON)
- if i <= 0:
- if btn_clicked == True:
- GPIO.output(PIN_LED_RED, 0)
- GPIO.output(PIN_LED_GRE, 1)
- time.sleep(5)
- GPIO.output(PIN_LED_GRE, GPIO.HIGH)
- time.sleep(0.1)
- GPIO.output(PIN_LED_GRE, GPIO.LOW)
- time.sleep(0.1)
- GPIO.output(PIN_LED_GRE, GPIO.HIGH)
- time.sleep(0.1)
- GPIO.output(PIN_LED_GRE, GPIO.LOW)
- time.sleep(0.1)
- GPIO.output(PIN_LED_GRE, GPIO.HIGH)
- time.sleep(0.1)
- GPIO.output(PIN_LED_GRE, GPIO.LOW)
- GPIO.output(PIN_LED_RED, 1)
- i = 5
- i = i - 1
- GPIO.cleanup();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement