Today I worked on getting the sewn NeoPixels onto my brim. But first I needed to be absolutely sure I was sewing things in the right place. In developing my code I had been using the 16 NeoPixel ring to stand in for the sewn ones around my brim. I wanted to make sure I knew the direction and numbering of the pixels, so I wrote a simple sketch that turns each pixel a different color. This way I could visually assure myself about the placement on the brim. I labeled the ring for future reference.
I also wanted to be sure that when I turned right or left, the heading was correct as well. I modified my code so that it points north with one pixel, and the other pixels fade up and down red with a direct correlation to the heading value. When heading = 360, red value = 255, when heading = 0, red value = 0.
Here is the code I wrote, also available at https://codebender.cc/sketch:53734
//for a ring of 16 NeoPixels and LSM303 on a Gemma //Pointer pixel points to North while others fade up N E S W //using code from https://learn.adafruit.com/steam-punk-goggles?view=all //idea for pointer pixel from http://www.element14.com/community/groups/arduino/blog/2013/08/27/get-closer-challenge--navigation-glove //idea for library modification from http://www.slickstreamer.info/2014/02/led-bracelet-accelerometer-3dprinting.html #include <TinyWireM.h> #include "TinyLSM303_mag.h" #include <Adafruit_NeoPixel.h> #define Pin 1 #define numPixels 16 Adafruit_NeoPixel ring = Adafruit_NeoPixel(numPixels, Pin, NEO_GRB + NEO_KHZ800); TinyLSM303_mag lsm; // Pi for calculations - not the raspberry type const float Pi = 3.14159; void setup() { ring.begin(); ring.show();// Initialize all pixels to 'off' lsm.begin();// Initialize the sensors } void loop() { // Read the magnetometer and determine the compass heading: lsm.read(); int x = map(lsm.magData.x, -202, 224, -1000, 1000); int y = map(lsm.magData.y, -397, -3, -1000, 1000); // Calculate the angle of the vector y,x from magnetic North float heading = (atan2(y,x) * 180) / Pi; // Normalize to 0-360 for a compass heading if (heading < 0) { heading = 360 + heading; } byte d = map(heading, 0, 360, 0, 16);//map the heading to the size of the ring // d = d - 4;//compensate for brim direction // if (d < 0) // { // d = 16 + d; // } int c = map(heading, 0, 360, 0, 255);//converts heading into a valid color range //wipe the slate with a color relating to the heading for(byte i=0;i<numPixels;i++) { ring.setPixelColor(i,ring.Color(c, 0, 0)); } ring.setPixelColor(d, ring.Color(0, 150, 0)); //set the closest pixel in the ring to the heading ring.show(); }
Now I had fully mapped out where the pixels were going to go on the brim and was ready to sew. I have never worked with the stainless steel conductive thread before. It is very twisty and tangles much more than regular sewing thread. I did a test on some scrap before just diving in. I tried to be super careful with my stitches and knots. I began sewing the data lines first using a single strand of 2 ply thread. I started my knot between two pixels, sewed with a running stitch over to one of the pixels and securely sewed down the data pad. Then I sewed back over my previous line of stitching towards the other pixel, sewed down the data pad, and then sewed back to center to make my knot. This assured that any fray in the knot could not make contact with any other close by connections. For the power lines, I used a double strand of 2 ply thread and just slipped the thread between the felt and the fabric cover. I sewed each pad through the brim and connected them into a complete ring for better power distribution. After sewing, I sealed the ends of my knots from behind with clear nail polish. Since the sewn NeoPixels were only part of my setup, I needed a way to bridge between sewn and soldered. I made a tiny ring in the end on hookup wire and soldered it closed. Then I used a scrap of larger wire to pierce a hole in the brim just next to the pixel. I threaded the hookup wire through the hole, sewed a few stitches onto just the pad itself, and then securely stitched the tiny ring onto the pad. These wires were then glued into the lip of the brim going around to the left side, mulled over with a bias strip of flannel, and secured at the headsize wire with regular thread. Tested everything again, and it all worked fine.
Here is a step by step video of the process. (no sound)
Coming up next...
Finishing up the brim: covering the brim face, binding the edge, adding the sweatband.
Top Comments