-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRGB_led.py
More file actions
39 lines (35 loc) · 682 Bytes
/
Copy pathRGB_led.py
File metadata and controls
39 lines (35 loc) · 682 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
38
39
from pyfirmata import Arduino, util
import time
board = Arduino("COM4")
it = util.Iterator(board)
it.start()
red = board.get_pin("d:11:o")
green = board.get_pin("d:10:o")
blue = board.get_pin("d:9:o")
def led_red():
red.write(1)
green.write(0)
blue.write(0)
def led_green():
red.write(0)
green.write(1)
blue.write(0)
def led_blue():
red.write(0)
green.write(0)
blue.write(1)
def white():
red.write(1)
green.write(1)
blue.write(1)
#create as many colors you want by mixing leds
while True:
led_red()
time.sleep(1)
led_green()
time.sleep(1)
led_blue()
time.sleep(1)
white()
time.sleep(1)
board.exit()