-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRGBsmooth.py
More file actions
executable file
·61 lines (53 loc) · 1.09 KB
/
RGBsmooth.py
File metadata and controls
executable file
·61 lines (53 loc) · 1.09 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import math
def main():
rs = 10
gs = 70
bs = 10
ri = 1
gi = 1
bi = 1
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
red = GPIO.PWM(7, 100)
green = GPIO.PWM(11, 100)
blue = GPIO.PWM(13, 100)
red.start(rs)
green.start(gs)
blue.start(bs)
for i in range(0, 10000):
rs = rs + ri
gs = gs + gi
bs = bs + bi
if rs > 100:
rs = 100
ri = -1
if gs > 100:
gs = 100
gi = -1
if bs > 100:
bs = 100
bi = -1
if rs < 0:
rs = 0
ri = 1
if gs < 0:
gs = 0
gi = 1
if bs < 0:
bs = 0
bi = 1
red.ChangeDutyCycle(rs)
green.ChangeDutyCycle(gs)
blue.ChangeDutyCycle(bs)
time.sleep(.01)
red.stop()
green.stop()
blue.stop()
GPIO.cleanup()
if __name__ == "__main__":
main()