@heywpi | Adding new features, more Object-Oriented code

First here’s a video of me demonstrating a few of the new features:

So compared to the original version of this project, the following changes are as follows:

  • Added function that takes image from incoming tweet, finds most common color in the image and writes it to the LEDs.
  • Added fading between colors instead of just jumping between them.
  • Added routine to respond to users when an error occurs in their tweet, like it’s missing a color or something is spelled wrong.
  • Re-Wrote most of code into an objects and methods on that object to get rid of global variables.

A few notes on the new features:

The operation of the image ingestion feature is pretty simple. All you have to do is tweet an image at @heyWPI just like you would with text. It finds the most common color in the image and then writes it the the LEDs. Here’s an example:




It works pretty well. If you look at the code, you’ll see that I tried to make it as modular as I could so I can possibly improve the color detection algorithm moving forward without making major changes in the code. This required the system to have some kind of memory to keep track of the current values written to the LEDs. Originally, I was using global variables to solve this problem but it wasn’t all that clean so I made it all more object oriented.

As for the fading You can sort of see it in the video, but the fading between colors looks really nice, especially from and to opposite complex colors like purple to orange.

A big problem I had with different people using the project was that sometimes people would use an invalid color. I implemented a default message to send if a received tweet didn’t have a color in the text or didn’t have an image in the body.

Want to make one?

@heywpi | How To Build Version 0_1_X

1. Install the prerequisites for the python code with the following:

2. Download the main heyWPI.py file

3. Download the LEDFuns2.py file for driving the LEDs – Place it in the same directory as heyWPI.py

4. Download the Log.py file for getting feedback on the status of the system – Place it in the same directory as heyWPI.py

5. Run the following commands in the same directory as heyWPI.py, this allows the Pi to drive the LEDs. More info on this step here:

6. Now enter your twitter api information into the heyWPI.py file at the top of the heyWPI class. If you don’t have twitter API info click here to get that for free!

You should be ready to rock and roll on the software side, now let’s look at the hardware schematic.


I’ve tried to make this as simple as possible, but it probably isn’t the best way to drive these LEDs, moving forward I’d like to drive these strips with a constant current.

Here are the parts to build it:

If you end up building this let me know!

@heywpi | Twitter Interaction, Bringing it All Together

Here’s a video of the whole thing in use!

Using the python library, tweepy, getting the twitter interaction to work was actually very simple. The downside is that I can only retrieve mention data every 60 seconds due to Twitter’s API rate limiting.

The circuit is very simple, the RGB led strip I have is common anode, so I used N-Channel mosfets attached to pins 18 (Red), 23 (Green) and 24 (Blue). For the camera, I’m using a spare raspberry pi camera module I have.

For the names of the colors you can write to the lights, I went with the 140 X-11 colors. I figured it was a good spectrum of colors.

The source code for the whole project will keep getting updated, so check here for the most recent versions of each file.

I’d love to expand the scale of the project, if you’re a student at wpi and would like on of these in your window, please email me at the addressed listed in the about section of my website.

Thanks for reading!

Hey! This post was written a long time ago, but I'm leaving it up on the off-chance it may help someone, but proceed with caution. It may not be a good idea to blindly integrate this code or work into your project, but instead use it as a starting point.

@heywpi | Pi-Blaster Python “wrapper” With RGB value Inputs

PWM with a Raspberry Pi is tricky. There is an official meathod of doing this, but I’ve found that when driving multiple channels (like 3 for an RGB LED) it doesn’t work to well and is noticeably shaky when transitioning to new PWM cycles.

Looking for alternatives, I found pi-blaster. From their github:

This project enables PWM on the GPIO pins you request of a Raspberry Pi. The technique used is extremely efficient: does not use the CPU and gives very stable pulses.

It was pretty simple to create a utility to drive my RGB LEDs with. My code can be found here.

To install pi-blaster for use with this code, you’ll need to download and install like so.

Make sure you are in the same directory as LEDFuns.py

The pi-blaster directory should be within the same directory as the LEDFuns.py file.

Thanks for reading! More on this project soon.

Hey! This post was written a long time ago, but I'm leaving it up on the off-chance it may help someone, but proceed with caution. It may not be a good idea to blindly integrate this code or work into your project, but instead use it as a starting point.