Skip to content

Commit

Permalink
feat(simple-led) - finalize example with 1 led
Browse files Browse the repository at this point in the history
  • Loading branch information
TeodorDre committed Jun 7, 2020
1 parent aa611f0 commit da6baca
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions simple-led/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import RPi.GPIO as GPIO
import time


def get_pin_number(number):
Expand All @@ -8,15 +9,33 @@ def get_pin_number(number):
gpio_port_number = get_pin_number(18)


def check_gpio_is_enabled():
channel_is_on = GPIO.input(gpio_port_number)

return channel_is_on


def start_app():
GPIO.setmode(GPIO.BCM)

GPIO.setup(gpio_port_number, GPIO.OUT)

GPIO.output(gpio_port_number, True)
if check_gpio_is_enabled():
print('Gpio pin was enabled')
GPIO.output(gpio_port_number, gpio_port_number)

while True:
GPIO.output(gpio_port_number, True)
time.sleep(1)

GPIO.output(gpio_port_number, False)
time.sleep(1)


try:
start_app()
except Exception as e:
print(e)
GPIO.cleanup()

finally:
GPIO.cleanup

0 comments on commit da6baca

Please sign in to comment.