RGB Rainbow

This commit is contained in:
L3D 2024-03-24 22:48:05 +01:00
parent 2af4abbcaa
commit fb45fba690
No known key found for this signature in database
GPG key ID: AD65B920933B4B20
3 changed files with 40 additions and 0 deletions

0
detect_buzz.py Normal file → Executable file
View file

View file

@ -1 +1,3 @@
RPi.GPIO
gpiozero
rpi_ws281x

38
rgb_rainbow.py Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Example RGB to Neopixel LED
"""
from rpi_ws281x import Adafruit_NeoPixel, Color
# NeoPixel configuration
PIN_NEO_PIXEL = 18
NUM_PIXELS = 24
DELAY_INTERVAL = 50
# Create NeoPixel object
NeoPixel = Adafruit_NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL)
NeoPixel.begin() # Initialize NeoPixel strip object
try:
while True:
# Turn on all pixels to green
for pixel in range(NUM_PIXELS):
NeoPixel.setPixelColor(pixel, Color(0, 255, 0))
NeoPixel.show()
time.sleep(DELAY_INTERVAL / 1000.0)
time.sleep(2)
# Turn on all pixels to red
for pixel in range(NUM_PIXELS):
NeoPixel.setPixelColor(pixel, Color(255, 0, 0))
NeoPixel.show()
time.sleep(DELAY_INTERVAL / 1000.0)
time.sleep(2)
except KeyboardInterrupt:
# Clean up code before exiting the script
for pixel in range(NUM_PIXELS):
NeoPixel.setPixelColor(pixel, Color(0, 0, 0))
NeoPixel.show()
time.sleep(DELAY_INTERVAL / 1000.0)