Programmable Ambient Light for External Display

Introduction: Programmable Ambient Light for External Display

This project helps you setup ambient light for your external monitor or tv lets you control the following from the comfort of ANY device having a web browser and connected to your router.

  1. LED Colour
  2. Frequency of blinking giving a DJ effect
  3. Set different colors for each side of the display

Supplies

WS2801 LED Strip - 1X

Connecting Wires

Raspberry Pi - any model

External Power Supply

Step 1: Configure You Pi

Boot up your PI and enable the SPI bus by following the below commands.

sudo raspi-config

Enter your password if prompted. Now go the "Advanced Options" and enable the SPI.

After that, install the dependencies.

sudo apt-get update<br>sudo apt-get install python-pip -y 
sudo pip install adafruit-ws2801
sudo pip install flask

Step 2: Making the Connections

Now, its time to make the wire connections

Connect your external 5V supply + to the strip's 5V and connect the combine the power supply ground to PI's ground and connect it to strip's GND.

CK and SI will be connected to the PI's SPI interface.

CK / CI : Pin 23 (SCKL)

SI / DI : Pin 19 (MOSI)

Step 3: Test If Connections Are Working Fine

After all the connections are made, it is time to test our strip.

Create a new python file.

nano ./strip-test.py

Now, paste the following code in it, and save the file. Replace the LED_COUNT value i.e. 32 with the number of LEDs you have on your strip.

import time
import RPi.GPIO as GPIO
 
import Adafruit_WS2801
import Adafruit_GPIO.SPI as SPI

# Configure the count of pixels:
LED_COUNT = 32
SPI_PORT   = 0
SPI_DEVICE = 0
pixels = Adafruit_WS2801.WS2801Pixels(LED_COUNT, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE), gpio=GPIO)

def rainbow_cycle(pixels, wait=0.005):
    for j in range(256): # one cycle of all 256 colors in the wheel
        for i in range(pixels.count()):
            pixels.set_pixel(i, wheel(((i * 256 // pixels.count()) + j) % 256) )
        pixels.show()
        if wait > 0:
            time.sleep(wait)
pixels.clear()
pixels.show()
rainbow_cycle(pixels, wait=0.01)

Your LED strip should now glow with all colors. If it does not, check your connections and make sure it is working before proceeding to the next step.

Step 4: Customising Colours and Blinking From Web

Now, it is time to set up a webserver to help us customize the strip colors and blinking from any device.

Clone the code.

git clone <a href="https://github.com/DefCon-007/instructable-led" rel="nofollow">https://github.com/DefCon-007/instructable-led</a>

Update the led count in the variable LED_COUNT in file "led.py".

Depending on how you stuck the LEDs to your display, update the following variables in "rgbStrip.py" file.
STRIP_EXTRA, STRIP_BOTTOM, STRIP_RIGHT, STRIP_TOP, STRIP_LEFT

Run the flask server

python ./led.py

Now, open the browser on any of the devices connected to your router and enter the IP address of your PI with port 1234. For e.g. if the IP of your Pi is 192.168.1.120, you should open http://192.168.1.120:1234 and you should see a website similar to the image.

Now you can select a color for each side of your monitor

LED Strip Speed Challenge

Participated in the
LED Strip Speed Challenge

Be the First to Share

    Recommendations

    • Maps Challenge

      Maps Challenge
    • Summer Fun: Student Design Challenge

      Summer Fun: Student Design Challenge
    • Fruit and Veggies Speed Challenge

      Fruit and Veggies Speed Challenge

    Comments

    0
    Elaina M
    Elaina M

    1 year ago

    Looks like a real party ! Thanks for sharing :)