diff --git a/rgb_rainbow.py b/rgb_rainbow.py index f7dc7eb..57cda22 100755 --- a/rgb_rainbow.py +++ b/rgb_rainbow.py @@ -9,7 +9,7 @@ from rpi_ws281x import Adafruit_NeoPixel, Color # NeoPixel configuration PIN_NEO_PIXEL = 18 NUM_PIXELS = 24 -DELAY_INTERVAL = 0.01 +DELAY_INTERVAL = 0.001 # Create NeoPixel object NeoPixel = Adafruit_NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL) @@ -19,11 +19,12 @@ def wheel(pos): """Generate rainbow colors across 0-255 positions.""" pos = pos % 256 # Ensure pos stays within 0-255 range if pos < 85: - return Color(int(pos * 3), int(255 - pos * 3), 0) - if pos < 170: - pos -= 85 - return Color(int(255 - pos * 3), 0, int(pos * 3)) - return Color(0, int(pos * 3), int(255 - pos * 3)) + return Color(pos * 3, 255 - pos * 3, 0) + pos -= 85 + if pos < 85: + return Color(255 - pos * 3, 0, pos * 3) + pos -= 85 + return Color(0, pos * 3, 255 - pos * 3) try: while True: