DesignSpark Electrical Logolinkedin

A Winter Wearable Project

Up-cycling a drab Christmas jumper by adding Adafruit Flora NeoPixels.

I loved last year’s Christmas jumper, it was so soft and cosy! Unfortunately it was a little boring… with only a white and grey pattern it didn’t really stand out in the sea of funky Christmas jumpers available. With wearable tech becoming increasingly popular, what I decided I would do is make my own bit of wearable tech by up-cycling my old festive jumper with some eye-catching LEDs.

There are many compact microcontroller platforms readily available now, which means you can now easily make your own simple wearable. I decided I would go with the Adafruit Flora, which is an Arduino-compatible wearable electronics platform. This has a whole family of sensors and peripherals and can be powered from a LiPo battery too, making it perfect for wearable tech.

I also decided to use the Flora smart RGB NeoPixels. These are smart, individually-addressable RGB LEDs and strips based on the WS2812, WS2811 and SK6812 LED/drivers, using a single-wire control protocol. These can be chained together and addressed individually/sequentially and when connected to a microcontroller, the output of one NeoPixel is connected directly to the input of the next.

NeoPixels are supported by an Arduino library. Initially I wasn’t quite sure how the NeoPixels worked: it wasn’t clear at all how they could be individually addressed even though connected in series on the data bus. When I looked at the comments in the simple.ino example on the Github repo for the NeoPixelit soon became clear. When there are several NeoPixels connected in series across the data pins, it is stipulated in the sketch that each NeoPixel is assigned a number in setup, this means that each pixel can be controlled individually when all connected to the same data pin.

Following downloading the appropriate libraries, as detailed in the Adafruit NeoPixel Überguide, I had to decide how I wanted my NeoPixels to behave. I ran through example sketches and found one which fades through the colours of the colour wheel. I thought this would be pretty cool to do with white and blue (thinking these are winter colours) so the NeoPixels would gently fade from white to blue and back to white and so on.

I knew that white was (127, 127, 127) and that blue was (0, 0, 255). initially I tried incrementing these integers until the white was blue, so subtracting one each time from red and green while adding one to blue, like so:

(127, 127, 127)
(126, 126, 128)
(125, 125, 129)
(124, 124, 130)
(123, 123, 131)

etc.

This was a little bit jumpy and didn’t have a smooth transition between colours, what I wanted was for it to smoothly fade like it did in the example I ran previously. Below is the section of code which controls the rainbow function. I figured that I could use something similar to this to get the pixels to fade instead of jump from one shade to the next.

void rainbow(uint8_t wait) {
   uint16_t i, j;

   for(j=0; j<256; j++) {
     for(i=0; i        strip.setPixelColor(i, Wheel((i+j) & 255));
     }
     strip.show();
     delay(wait);
   }

What I decided to do was include a for loop, so that I was able to get the NeoPixels to fade gently from blue to white.

    for(int count = 0; count <127; count ++)
       colorWipe(strip.Color(count, count, 255-count), 60);

This worked great and I had myself a NeoPixel fading from blue to white, however, when it came to go back to blue from white it was just jumping instead of fading. I didn’t really like how this looked and ideally wanted them to fade gently between the two colours continuously. To do this I included a second for loop which worked in reverse to the one above, which made the NeoPixels gently fade back to blue again.

void loop() {
    for(int count = 0; count <127; count ++)
       colorWipe(strip.Color(count, count, 255-count), 60);
    for(int count = 0; count <127; count ++)
       colorWipe(strip.Color(127-count, 127-count, 127+count), 60);
}

Due to the lighting where the video was taken it is difficult to see the colours changing.

Since the sketch worked on a set of three NeoPixels I decided it was time to start sewing. Before I could actually sew any components I needed to decide where they were going to go. I thought that a NeoPixel in the middle of each snowflakes on the jumper would look quite nice, since it would look as though the snowflakes were twinkling. I love that this brought colour to the jumper and made it look a lot cooler – pun intended – this would require the use of seven NeoPixels.

To begin with I mapped out which NeoPixel I would sew first and navigated this in my head so I knew I wouldn’t have any shorts. I began with the furthest away NeoPixel and started sewing to the next closest, stitching all the data pins together first. Sewing with conductive thread is quite different to normal sewing, the thread is a lot thicker and a lot harder to work with – the thread needs to be treated like you would a bare wire, you can’t cross paths without creating a short.

Once all the data lines were connected I then sewed GND and VCC from the Flora, once again ensuring not to get too close to the data stitches. Wherever I needed to knot the thread I then secured this with clear nail varnish to prevent it coming undone.

 

Because I had decided that I would stick the components to the inside of the jumper I needed to cover the Flora. This was done by making a pouch which could sit over the top on the Flora and be secured with Velcro at the bottom to create a flap. This doubled as somewhere to secure the LiPo battery while still being able to access the flora.

To finish the jumper I connected the Flora via micro USB to my laptop and then uploaded the sketch through the Arduino IDE. And here we have a working NeoPixel Christmas jumper! Given its a little bit temperamental – although it is the first time I have made a wearable project – I think it turned out pretty well!

What I really like about this project is that I don’t have to stick to fading blue and white LEDs and depending on the occasion I can make them do all sorts, by changing a few lines of code I can easily change the colours of the NeoPixels and even make them flash.

Trainee Electronics Engineer for AB Open. Love to try new things and build interesting projects!