Monday, January 25, 2016

NeoBracelet by the Brain

I've been dreaming of a reasonable way to make a bracelet full of neopixels for a while now.  I finally realized a way to do it so I will share my process with the world.  I only made my own random blinking code so if anyone would like to write custom code for a nice animation or another neat idea, please send me a message on g+.

This project takes a normal bracelet and basically makes it "taller" by stacking items on top.  So the final product is going to look a tad more beefy compared to most bracelets.   But with the batteries I used, it should stay powered on for at least 8 hours.

This project was featured on Adafruit's blog

Obligatory Disclaimer:
While I shouldn't have to say this anyway....I am not responsible for anything you do.  I don't care if you burn your house down or worse.  This information is for educational purposes only and you are responsible for your own actions.
Physical Warning:
This task does involve some soldering.  If you have no desire to do that, then you can find someone that knows how to solder or just go do a different project.  You can always locate your nearest Hackerspace and there should be plenty of people there that can assist.
Copyright Warning:
This project is my intellectual property that I am giving to the open-source community for non-profit use only.

List of materials:
  • One meter Adafruit Neopixels (60/meter) with black backing.  If you want to go ultra bling then you can get the 120/meter strips. 
  • One plaint leather bracelet, dark in color, preferably with buttons or some easy and compact connection.  pay attention to the actual width of the bracelet.  the wider the bracelet the more rows of neopixels you can use.
  • One Adafruit Trinket Pro 3v.  Dont bother using gemma or normal trinket, you need a lot of ram and code space to run even basic programs and this project begs creative code.
    NOTE: in some images below, you will notice I used a gemma at first.  this is how I learned of the above need for extra code space, but a gemma technically will work with its own limitations if you still prefer to use it.
  • Low voltage wire, threaded.  Cat5 cable works great. 
  • Two Li-Po batteries, 650mAh each
    • Note: if you use lipo batteries, you will need a lipo charger.  I use this one because it has a handy "DONE" indicator light. 
  • One JST extension cable
  • Soldering iron & solder
  • One mini push button
  • Hot glue gun & hot glue
  • Gorilla Glue or some other strong adhesive for leather
  • Binder clips
  • Heat shrink and heat gun
  • Wooden dowels/sticks.  (can be found at any craft store)
  • Hair spray
  • Electrical tape (black)

 First put on your bracelet and find the best locations to place your batteries.    Use a marker to trace where they should go so you can glue them later.

 Before gluing anything, first you want to combine the batteries.  use low voltage cable to combine both red wires into one single wire, and the same for the two black wires.  this will make one large 1300mAh battery.  give the new wires enough slack to work with for positioning. 
Now glue the batteries to the bracelet and use the binder clips to hold them in place until fully dry.  Despite the images below, don't bother gluing the board to the bracelet yet.  you still need to solder.

 Now put on the bracelet again and use the neopixels to measure the required length for each strip of pixels.  you want to wear the bracelet for this because when the bracelet goes from flat to round, the strips of pixels will tighten.

Cut as many strips of pixels that your bracelet can handle based on the width.   Cut them in the center of the copper leads. 

Remove the pixels from the plastic sheathing.  then solder the pieces back together with a very small length of low voltage cable.  The length will depend on how you want to order the array of pixels.   My array goes back and forth, but you could have them all start on one end and end at the other side.  This method would require longer lengths of cable.  Either way you need to solder the leads where they were cut to once again make one long strip.   also make the initial 3 connections at the start of the strip to be connected to the board.

Note:  you could make multiple independent strips instead of combining them together, but I am not discussing that here.

Cut some wooden dowels that are the same thickness as the batteries.  Cut them to the length that matches the width of the bracelet.   these dowels are to be used as filler between the batteries so the pixels do not sink.   Glue the dowels to the bracelet in between the batteries but spaced apart evenly.

Cut the ends off the JST extension cable.   the female end needs to connect to the matching color wires of the battery and should be positioned so it can reach the male end at any time.   the male end needs to join the power wires on the neopixel strip. so connect the black wire to the neopixel GND wire, and the red wire to the neopixel 5v wire.   both of these new unisons will need one more single low voltage wire attached to them as this wire is needed to go directly to the board for soldering.  the neopixel data wire can go directly to the board if it's long enough.

Now solder the wires to the board.  the neopixel 5v wire combo goes to the BAT pin on the board (or for gemma use VBATT).    the neopixel GND combo wire goes to the GND pin on the board found next to the BAT pin.  the neopixel data pin goes to pin 8 on the board.   Solder the push button to pins 6 and 3.

Upload the code included below to the board.  Use this time to test and troubleshoot as needed.

Once the strip is fully connected, coat it with hair spray to give it a little waterproofing.  there are other things that can be used for the same purpose, but be careful not to obstruct the LEDs with too thick a coat of anything.

Use a small amount of hot glue on the ends of the strips of neopixels where the wires are connected.  This will better secure the wires from being pulled apart accidentally.
Now place the strips over the bracelet and hide any cabling as best you can.  Glue the strips across the batteries and dowel pieces making a nice upper coat of pixels.  glue the board somewhere under the pixels and be sure the usb connection is easily accessible at all times.  I placed my board at the end.  As shown below, you can see the usb port. 

 Once the strips are in place and secured, cut long strips of electrical tape in half-width pieces.  Place the electrical tape over the copper leads and wrap it around the bracelet.

Connect the JST ends together and verify the unit works as expected. Enjoy your bracelet.

The push button runs the same program but changes between a fully illuminated grid versus a partially illuminated grid.  For example, the code is running a random color generation program.  If the random color matches the target color (RED) then that pixel stays that color.  This will continue until all pixels are red.  Then a new random color is chosen as the target color and the program tries again to fill the pixels with that matching color.

If the button is pushed, the program changes to on/off mode where if the random color does not match the RGB value, then there is a 50% chance that instead of filling the random pixel with that random color, it will instead just turn off the pixel and move onto the next random pixel.   The less illuminated pattern is a tad easier on the eyes in some situations and gives more of an impression that the cpu is working.

Also, the odds of the color matching the target value is quite low, so you can run this code all day and maybe you will match one or two pixels. 


#include <Adafruit_NeoPixel.h>
#define PIN 8
#define BUTTON 3
#define Pixels 40
Adafruit_NeoPixel strip = Adafruit_NeoPixel(Pixels, PIN, NEO_GRB + NEO_KHZ800);

int alpha;int dir = 1; int flip;
int minAlpha = 25;int maxAlpha = 100;int alphaDelta = 5;
int cycle = 1; int tgtx=0;int tgty=0; int tgtz=0;
int x=0;int y=0;int z=0;int spot=0;
int pause = 0;int start=0;int mode=1;
int temp = 0; int listsize = 40;int state = 0;
int list[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};

void setup() {

digitalWrite(BUTTON, LOW);
digitalWrite(6, HIGH);
    tgtx = 254;
    tgty = 0;
    tgtz = 0;
for(int a=0;a<5;a++){
      strip.setPixelColor(a, 0,0,0);};

void loop() {

if(digitalRead(BUTTON) == HIGH){ state++;delay(500);  }
if(state > 1){ state=0; }
int count=0;int loop=0;
for(int a=0;a<40;a++){
count += list[a];

if(count == 0){
    //reset when full
    tgtx = random(254);
    tgty = random(199);
    tgtz = random(199);
    int list[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
    for(int a=0;a<5;a++){
          strip.setPixelColor(a, 0,0,0);};delay(200);
    for(int a=0;a<5;a++){
          strip.setPixelColor(a, 0,0,254);};delay(200);
    for(int a=0;a<5;a++){
      strip.setPixelColor(a, 0,0,0);};delay(200);
mode = random(2);
int rand = 0;int spot=0;
  spot = random(listsize);
  //Serial.print("spotA=");  Serial.println(spot);
  rand = list[spot];
}while(rand == 0);
pause = random(10);
x = random(255);
y = random(200);
z = random(200);
Serial.print("state = ");  Serial.println(state);

if(x==tgtx && y==tgty && z==tgtz){  
    //remove element from array
    list[spot] = 0; Serial.print("list-");Serial.print(spot);  Serial.print(" = 0");
    strip.setPixelColor(spot, x, y, z);
    if(mode==0 && state==0){   // turn off
        strip.setPixelColor(spot, 0,0,0);}
    else{    // or change random color
        strip.setPixelColor(spot, x, y, z); }; 
} // end if else

} // end void   

No comments:

Post a Comment