Exemple #1
0
import time
import board
from rgb import RGB  # import the RGB class from the rgb module

r1 = board.D3  #sets all pins up
g1 = board.D4
b1 = board.D5
r2 = board.D1
g2 = board.D2
b2 = board.D7

myRGB1 = RGB(r1, g1, b1)  # create a new RGB object, using pins 3, 4, and 5
myRGB2 = RGB(r2, g2, b2)  # create a new RGB object, using pins 8, 9, and 10

myRGB1.red()  # Glow red
myRGB2.green()  # Glow green
time.sleep(1)
myRGB1.blue()  # Glow blue
myRGB2.cyan()  # Glow... you get it...
time.sleep(1)
myRGB1.magenta()  # Did you know magenta isn't in the rainbow?
myRGB2.yellow()  # Like you learned in first grade, red and green make... huh?
time.sleep(1)
myRGB1.rainbow1(
)  # Nicely fade through all the colors of the rainbow at the given rate.  Oooooh, pretty!
myRGB2.rainbow2(
)  # Nicely fade through all the colors of the rainbow at the given rate.  Oooooh, pretty!
time.sleep(1)
Exemple #2
0
import board  #pylint: disable-msg=import-error
import time
from rgb import RGB

#pin numbers for each color
r1 = board.D2
g1 = board.D3
b1 = board.D4
r2 = board.D5
g2 = board.D6
b2 = board.D7

#declare objects
LED1 = RGB(r1, g1, b1)
LED2 = RGB(r2, g2, b2)

#call methods from class
LED1.red()
LED2.green()
time.sleep(1)
LED1.blue()
LED2.cyan()
time.sleep(1)
LED1.magenta()
LED2.yellow()
time.sleep(1)
delay = 1

myRGB1 = RGB(pins1)
myRGB2 = RGB(pins2)

print("go")

while True:
    myRGB1.red()
    myRGB2.green()
    time.sleep(delay)
    myRGB1.green()
    myRGB2.red()
    time.sleep(delay)
    myRGB1.blue()
    myRGB2.cyan()
    time.sleep(delay)
    myRGB1.cyan()
    myRGB2.blue()
    time.sleep(delay)
    myRGB1.magenta()
    myRGB2.yellow()
    time.sleep(delay)
    myRGB1.yellow()
    myRGB2.magenta()
    time.sleep(delay)
    myRGB1.white()
    myRGB2.white()
    time.sleep(delay)
    myRGB1.black()
    myRGB2.black()
Exemple #4
0
import time
import board  #pylint: disable-msg=import-error
from rgb import RGB

r = board.D2
g = board.D3
b = board.D4

myRGB = RGB(r, g, b)

print("go")

while True:
    myRGB.red()
    time.sleep(0.1)
    myRGB.green()
    time.sleep(0.1)
    myRGB.blue()
    time.sleep(0.1)
    myRGB.cyan()
    time.sleep(0.1)
    myRGB.magenta()
    time.sleep(0.1)
    myRGB.yellow()
    time.sleep(0.1)
    myRGB.white()
    time.sleep(0.1)
    myRGB.black()
    time.sleep(0.1)
    myRGB.rainbow()
Exemple #5
0
import time
import board
from rgb import RGB  # import the RGB class from the rgb module

r1 = board.D3
g1 = board.D2
b1 = board.D1
r2 = board.D12
g2 = board.D11
b2 = board.D10

myRGB1 = RGB(r1, g1, b1)  # create a new RGB object, using pins 3, 4, and 5
myRGB2 = RGB(r2, g2, b2)  # create a new RGB object, using pins 8, 9, and 10

while True:
    myRGB1.red()  # Glow red
    myRGB2.yellow()  # Glow green
    time.sleep(1)
    myRGB1.yellow()  # Glow blue
    myRGB2.green()  # Glow... you get it...
    time.sleep(1)
    myRGB1.green()  # Did you know magenta isn't in the rainbow?
    myRGB2.cyan(
    )  # Like you learned in first grade, red and green make... huh?
    time.sleep(1)
    myRGB1.cyan()  # Did you know magenta isn't in the rainbow?
    myRGB2.blue(
    )  # Like you learned in first grade, red and green make... huh?
    time.sleep(1)
Exemple #6
0
myRGB1 = RGB(r1, g1, b1)  # create a new RGB object, using pins 2, 3, and 4
myRGB2 = RGB(r2, g2, b2)  # create a new RGB object, using pins 5, 6, and 7

#print(myRGB1.kind)
#print(myRGB2.kind)
myRGB1.change_name("rex")

myRGB1.red()  # first RGB LED glow red

myRGB2.green()  # second RGB LED glow green

time.sleep(1)

myRGB1.blue()  # first RGB LED glow blue

myRGB2.cyan()  # second RGB LED glow cyan

time.sleep(1)

myRGB1.magenta()  # first RGB LED glow magenta

myRGB2.yellow()  # second RGB LED glow yellow

time.sleep(1)
# extra spicy (optional) part
myRGB1.rainbow(
    rate1
)  # first RGB LED Fade through the colors of the rainbow at the given rate.

myRGB2.rainbow(
    rate2