Search This Blog

Wednesday, April 26, 2017

Adafruit LED Ring


Hi everyone!

Have you ever been one to take arts and crafts kits and follow the instructions to make them? How about taking a large LEGO kit and following the model to build the coolest buildings and cars? Well, based on everything in society shifting towards a technology based product, a company named Adafruit offers items that you can use to build whatever you can imagine.

For example, some people have made LED ring earrings or bracelets along with a variety of other products! Adafruit has an entire portion of it's website dedicated just to the invention and final products that are created by people who use Adafruit components. Visit this website to look at all the awesome (and completely geeky) inventions that people have come up with using LEDs similar to what I worked with.

While at my internship, I have been working with the NeoPixel Ring which is basically 24 LED rings daisy chained together. Using a program called "MPLAB X IDE", and a debugger I have been programing the ring to light up in different ways based on how much data is given to each LED ring. Using C programming, I started to send each LED lights a specific amount of data from 0-256 bits. The reason that each LED light receives information is because a different amount of data changes the brightness. Furthermore, each LED has three different lights. One is green, one blue, and one red.

Okay let's step back to kindergarten for a moment! What are red blue and green class? Correct! They are primary colors. I know it was a while ago but when you think back to kindergarten you probably remember mixing the colors together and being completely surprised when a I new color formed. Well, as silly as it may sound. This happened to me when I was working on this project. On accident, I had sent both the red and the blue LED data... resulting in a purple color. At first it surprised me and I wondered if I messed up somehow given that I was expecting blue. However, after thinking about it a bit more, I realized that by sending data to both of the lights the result was a combination of them.

To give you a better idea of what I mean when I say "send the LED data" I wanted to include part of my code here. Now mind you, my code ended up being over 2,000 lines (crazy right!?!). This is the part that established the background color for the ring while the other lights rotated through changing color.

for(k=0; k<50; k++)
    {
        for(i=0; i<24; i++)                    // Generate Blue Background
        {
           
            Ring_Green_Data[i] = Off;
            Ring_Red_Data[i] = Off;
            Ring_Blue_Data[i] = 255;
        }

In basic terms, this is telling the ring to light up with a very very bright colored blue for all 24 LEDs. 255 is the level of maximum intensity for each color. Off means that the light is receiving 0 bits of data, thus it doesn't produce a color. Likewise, If I were to set "Ring_Green_Data[I] = 255" and the red and blue to off then you would see a very bright green.

To see a purple color I could turn both the red and the blue on to a medium intensity by sending 128 bits of both colors.

for(k=0; k<50; k++)
    {
        for(i=0; i<24; i++)                    // Generate Purple Background
        {
           
            Ring_Green_Data[i] = Off;
            Ring_Red_Data[i] = 128;
            Ring_Blue_Data[i] = 128;
        }

For the project I was working on, we sent each LED it's own color "assignment." The code you see above was to set the "background " color. Once this was established, the other color assignments were sent out to the specific LEDs that we wanted. For instance, if we wanted the 12th LED on the string to be blue we would sent the data to that LED by saying something like "Ring_Blue_Data[12] = 128." This would result in LED #12 showing up as a medium intensity blue light.

Okay, I know this is probably a lot of information to process and a lot of it doesn't make sense. Basically, if you spend a few weeks reading data sheets all over the internet and practicing (with a lot of trial and error) the product is something really awesome. Through this blog I wanted to show that while you may not know how to do something right away just try - it's interesting to see what you come up with!!


Here some example of bracelets and earrings using Adafruit NeoPixel rings.

1 comment:

  1. How has your appreciation of what goes into the small little pieces of technology we take for granted changed over the course of your project?

    ReplyDelete