diff --git a/detect_buzz.py b/detect_buzz.py old mode 100644 new mode 100755 diff --git a/requirements.txt b/requirements.txt index e9a7937..838f4a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ +RPi.GPIO gpiozero +rpi_ws281x diff --git a/rgb_rainbow.py b/rgb_rainbow.py new file mode 100755 index 0000000..6e8a382 --- /dev/null +++ b/rgb_rainbow.py @@ -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)