The Raspberry Pi is one of the best devices to get into technology DIY-ing. It’s simple, has a lot of documentation, and is a surprisingly good computer for its price point. I honestly learned a lot about python scripting, wiring, and various forms of troubleshooting from this project, despite the massive pain everything was to get working. The difficulty of this project was mostly on me, however, since I somehow chose to take on a weird niche project that ended up having me write a whole python script from scratch. At least I now know the best ways to search StackOverflow for python problems!

My project is a time-managed AdaFruit Neopixels LED strip that slowly changes its color from dark blue, to light blue, then to an orange between the times of 7 AM to 10 PM, turning off at night. I created my own python script using too many if statements for this kind of project. The things you will need to make this project at home are:

  1. Raspberry Pi
  2. Any AdaFruit Neopixels LED Strip
  3. AC Power adapter (amperage and voltage depends on the LED Strip)
  4. Two M/F Jumper wires (make sure they’re different colors!)
  5. Terminal Block to AC Adapter
  6. Wire Strippers
  7. Screwdriver
  8. Keyboard, Mouse, and your Monitor of Choice (of course)

The first step is to prepare the wires on the LED strip and connect them to the terminal block adapter. Just get some wire strippers and strip the two middle black and red wires back just less than an inch or so, then use the screwdriver to screw the wires into the terminal block adapter. Red goes positive and black goes negative.

Next, we need to connect the Neopixels to the Pi. Connect the pi to your keyboard, mouse, and monitor, then get the jumper cables ready. The Pi should have GIPO pins ready to go. We’ll be using a ground pin and GIPO Pin 18. Use the jumper wires to connect the two remaining wires on the LED Strip, extending the white cable to GIPO 18 and extending the black wire to a ground pin. Once all the pins are connected, plug in the AC adapter to the block and an outlet and turn on the Pi.

Once the Pi is on, navigate to the terminal and perform two commands. These commands install the required Adafruit python libraries to run the script I made for this project.

sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel

sudo python3 -m pip install --force-reinstall adafruit-blinka

While the libraries are downloading, go to the web browser and download the python script from Dropbox at:

https://www.dropbox.com/s/kehlap4iehkjec6/LEDProject.py?dl=0

Once the script and all the libraries are installed, make sure that the LED Strip is working by creating a new file called test.py. Put this code in the file and change the ’30’ in line 3 to the number of LEDs on your strip. Save and run the file using the command in the terminal, ‘sudo python3 test.py’ while in its directory.

import board
import neopixel
pixels = neopixel.NeoPixel(board.D18, 30)
pixels.fill ((255,255,255))

These LED python scrips ONLY work if you run them through the terminal with ‘sudo python3’. Just running them in the file manager will not work! If all your LEDS are lit up white by now, then congratulations, all the hardware is set up properly!

The last thing you need to do is to open up the LEDProject.py script in your text editor of choice and change the 30 in this line to the same number you entered in the test script:

pixels = neopixel.NeoPixel(board.D18, 30)

Save the file and run the script in the terminal using ‘sudo python3 LEDProject.py’. If the current time shows up in the terminal, the script is working! Depending on the Pi’s internal clock, it may take a few hours for the LEDs to sync themselves up to their intended time, but after that, the LED program is perfectly fine to run in the background.

If somebody wants to do their own thing with this project, pretty much all the documentation related to the NeoPixels with Python and the Pi is located over on the AdaFruit Website:

https://learn.adafruit.com/neopixels-on-raspberry-pi/python-usage

When I first started this project, I wanted to do something “different” and “fun”. I wholeheartedly regret this decision to do so much, but I would never choose any differently. There were a lot of things I wouldn’t have learned without forcing myself to figure out some seemingly-impossible problems. I learned some basic python programming, wiring, and problem-solving skills. Overall, this project was very good for me… but maybe not so much for my hair.

Categories: Uncategorized

1 Comment

Jerick Evangelista · December 1, 2020 at 7:20 pm

Awesome stuff, John! I imagine this’ll be something incredible to hook up to my future secondary pie once I wanna get all fancy with stuff. Hope it was safe to work with all this stuff, the wiring looks a little dangerous!

Leave a Reply

Avatar placeholder

Your email address will not be published.

css.php