How to Connect a LED Strip to a Raspberry Pi
Easy steps to connect the LED to the board. I will provide you a simple test script too.
How and What to Connect
I am not an electronics guy, so I followed a tutorial on this. I browsed different tutorials, but the most useful was the first one. Be careful and do things at your own risk! The tutorial I used: Raspberry Pi & RGB LED-Strips By David Ordnung. In the comment section you can ask for help or find some solutions for common problems. The steps are clear, I had no issues.
After the LED is connected you can find a place for it. I recommend you to put it on a place where you don’t see it visibly, you just see the light of it. If the LED strip is fully visible then it will look ugly plus it will burn your eyes out. I have put it under my desk, which is close to my bed.
Test Your LED
I made a python class which with controlling the LED especially in scripts becomes more easy. It includes a reset option, and it can also calculate the transition between colors. Clone my sunrise-pialarm repository or download the script from GitHub - 11Firefox11/sunrise-pialarm and import
LedController into your script. I have a post about this class too, check that out to know how it works: Python class to control a LED strip on a raspberry pi.
Test out your LED with the simple script bellow that goes through all the colors smoothly. It is in an infinite loop, so you will have to stop it from running. This script is also available at GitHub Gist: pialarm-test.py.
from time import sleep from led_controller import LedController controller = LedController() controller.red = 255 color_sequence = [ (255, 255, 0), (0, 255, 0), (0, 255, 255), (0, 0, 255), (255, 0, 255), (255, 0, 0), ] try: while True: for target_color in color_sequence: for new_color in controller.transition(*target_color): controller.red, controller.green, controller.blue = new_color sleep(0.01) except KeyboardInterrupt as e: controller.reset()
The Idea and Details About Sunrise Pialarm