def blue(i, color):
strip.setPixelColor(i, color)
strip.setPixelcolor(i+1, color)
print
time.sleep(3)
while True:
blue(0, 0, 255)
from rpi_ws281x import *
import time
LED_COUNT = 233 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 10 # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
def examplefunction(i, color): #This is a function/definition. A function is a "group of code" that can be called from anywhere.
strip.setPixelColor(i, color) #We are using a variable called i that we later define, and the variable color that we later define.
strip.setPixelColor(i+1, color) #We are once again using the variable i, but this time we're adding +1 to it. What do you think will happen?
print('This is a function, we can execute multiple lines of code with just one command')
strip.show()
time.sleep(3) #Sleep for 3 seconds
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
strip.begin()
print ('Starting the program')
try:
while True:
examplefunction(1, Color(255, 0, 0)) #Here we define the variable I and the color that we want the function to use. What color should this mix into?
examplefunction(1, Color (250, 0, 0)) #Here we define the variable I and the color that we want the function to use.
exit() #Here we exit the program
except KeyboardInterrupt:
if args.clear:
colorWipe(strip, Color(0,0,255), 10)