-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRGBsine.py
More file actions
executable file
·37 lines (33 loc) · 790 Bytes
/
RGBsine.py
File metadata and controls
executable file
·37 lines (33 loc) · 790 Bytes
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
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import math
def main():
rs = 50
gs = 50
bs = 50
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, 100):
x = i
rs = 50 * (1.0 + math.sin(x + 0.0))
gs = 50 * (1.0 + math.sin(.5*x + 1))
bs = 50 * (1.0 + math.sin(x + 3))
red.ChangeDutyCycle(rs)
green.ChangeDutyCycle(gs)
blue.ChangeDutyCycle(bs)
time.sleep(.5)
red.stop()
green.stop()
blue.stop()
GPIO.cleanup()
if __name__ == "__main__":
main()