-
Notifications
You must be signed in to change notification settings - Fork 0
/
LED.py
35 lines (29 loc) · 809 Bytes
/
LED.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import threading
from time import sleep
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(5, GPIO.OUT)
GPIO.setup(6, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
led1 = GPIO.PWM(5, 200)
led2 = GPIO.PWM(6, 200)
led3 = GPIO.PWM(13, 200)
def led_glow():
t = threading.currentThread()
led1.start(0)
led2.start(100)
led3.start(0)
while getattr(t, "do_run", True):
pause_time = 0.004
for i in range(0, 101, + 1):
sleep(pause_time)
led1.ChangeDutyCycle(i)
led2.ChangeDutyCycle(i)
led3.ChangeDutyCycle(i)
pause_time = 0.012
for i in range(99, -1, -1):
sleep(pause_time)
led1.ChangeDutyCycle(i)
led2.ChangeDutyCycle(i)
led3.ChangeDutyCycle(i)